summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2024-11-26 14:44:36 +0700
committerstephanchrst <stephanchrst@gmail.com>2024-11-26 14:44:36 +0700
commit2f5430e4a50d6203f1a0d0b7b70786d766bd235f (patch)
treebee1f828604f17b4c5a43987e6080f2b8b69f2bb
parent75a1c83707d1c078e3e200e7bc3d3ca39497ad1c (diff)
change function of qty before test
-rwxr-xr-xindoteknik_custom/models/product_template.py33
1 files changed, 13 insertions, 20 deletions
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py
index df131ff6..8d044695 100755
--- a/indoteknik_custom/models/product_template.py
+++ b/indoteknik_custom/models/product_template.py
@@ -482,48 +482,38 @@ class ProductProduct(models.Model):
def _get_qty_incoming_bandengan(self):
for product in self:
- qty = self.env['stock.move'].read_group(
+ qty = self.env['v.move.outstanding'].read_group(
domain=[
('product_id', '=', product.id),
('location_dest_id', 'in', [57, 83]),
- ('state', 'not in', ['done', 'cancel', 'draft'])
],
- fields=['product_uom_qty'],
+ fields=['qty_need'],
groupby=[]
- )[0].get('product_uom_qty', 0.0)
+ )[0].get('qty_need', 0.0)
product.qty_incoming_bandengan = qty
def _get_qty_incoming_bandengan_with_exclude(self):
for product in self:
- qty = self.env['stock.move'].read_group(
+ qty = self.env['v.move.outstanding'].read_group(
domain=[
('product_id', '=', product.id),
('location_dest_id', 'in', [57, 83]),
- ('state', 'not in', ['done', 'cancel', 'draft'])
],
- fields=['product_uom_qty'],
+ fields=['qty_need'],
groupby=[]
- )[0].get('product_uom_qty', 0.0)
+ )[0].get('qty_need', 0.0)
product.qty_incoming_bandengan = qty
def _get_qty_outgoing_bandengan(self):
for product in self:
- # qty_outgoing = self.env['stock.move'].search([
- # ('product_id', '=', product.id),
- # # ('location_dest_id', '=', 5),
- # ('location_id', 'in', [57, 83]),
- # ('state', 'not in', ['done', 'cancel', 'draft'])
- # ])
- # qty = sum(qty_outgoing.mapped('product_uom_qty'))
- qty = self.env['stock.move'].read_group(
+ qty = self.env['v.move.outstanding'].read_group(
domain=[
('product_id', '=', product.id),
('location_id', 'in', [57, 83]),
- ('state', 'not in', ['done', 'cancel', 'draft'])
],
- fields=['product_uom_qty'],
+ fields=['qty_reserved'],
groupby=[]
- )[0].get('product_uom_qty', 0.0)
+ )[0].get('qty_reserved', 0.0)
product.qty_outgoing_bandengan = qty
def _get_qty_onhand_bandengan(self):
@@ -625,6 +615,8 @@ class OutstandingMove(models.Model):
reference = fields.Char(string='Reference', help='Nomor Dokumen terkait')
qty_need = fields.Float(string='Qty Need', help='Qty yang akan outgoing / incoming')
qty_reserved = fields.Float(string='Qty Reserved', help='Qty yang sudah ter-reserved jika outgoing')
+ location_id = fields.Many2one('stock.location', string='Location', help='Lokasi asal')
+ location_dest_id = fields.Many2one('stock.location', string='Location To', help='Lokasi tujuan')
def init(self):
# where clause 'state in' follow the origin of outgoing and incoming odoo
@@ -632,7 +624,8 @@ class OutstandingMove(models.Model):
self.env.cr.execute("""
CREATE OR REPLACE VIEW %s AS
select sml.id, sm.reference, sm.product_id,
- sm.product_uom_qty as qty_need, sml.product_uom_qty as qty_reserved
+ sm.product_uom_qty as qty_need, sml.product_uom_qty as qty_reserved,
+ sm.location_id, sm.location_dest_id
from stock_move sm
join stock_move_line sml on sml.move_id = sm.id
where 1=1