From cc6e4b9e48752ee54b42db2c16fae7cd5d5af1c4 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Fri, 23 May 2025 09:02:14 +0700 Subject: quick fix purchasing job conflict with manufacturing order sync to po --- indoteknik_custom/models/product_template.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'indoteknik_custom/models/product_template.py') diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index 89392033..6903b53e 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -913,7 +913,8 @@ class ProductProduct(models.Model): qty_onhand_bandengan = fields.Float(string='Onhand BU', compute='_get_qty_onhand_bandengan') clean_website_description = fields.Char(string='Clean Website Description', compute='_get_clean_website_description') qty_incoming_bandengan = fields.Float(string='Incoming BU', compute='_get_qty_incoming_bandengan') - qty_outgoing_bandengan = fields.Float(string='Outgoing BU', compute='_get_qty_outgoing_bandengan') + qty_outgoing_bandengan = fields.Float(string='Outgoing BU', compute='_get_qty_outgoing_bandengan', help='only outgoing from sales order bandengan') + qty_outgoing_mo_bandengan = fields.Float(string='Outgoing MO BU', compute='_get_qty_outgoing_mo_bandengan', help='only outgoing from manufacturing order bandengan') qty_available_bandengan = fields.Float(string='Available BU', compute='_get_qty_available_bandengan') qty_free_bandengan = fields.Float(string='Free BU', compute='_get_qty_free_bandengan') qty_upcoming = fields.Float(string='Qty Upcoming', compute='_get_qty_upcoming') @@ -1115,12 +1116,23 @@ class ProductProduct(models.Model): domain=[ ('product_id', '=', product.id), ('location_id', 'in', [57, 83]), + ('mo_id', '=', False) ], fields=['qty_need'], groupby=[] )[0].get('qty_need', 0.0) product.qty_outgoing_bandengan = qty + def _get_qty_outgoing_mo_bandengan(self): + for product in self: + records = self.env['v.move.outstanding'].search([ + ('product_id.id', '=', product.id), + ('location_id.id', 'in', [57, 83]), + ('mo_id.id', '>', 0) + ]) + qty = sum(records.mapped('qty_need') or [0.0]) + product.qty_outgoing_mo_bandengan = qty + def _get_qty_onhand_bandengan(self): for product in self: qty_onhand = self.env['stock.quant'].search([ @@ -1132,7 +1144,7 @@ class ProductProduct(models.Model): def _get_qty_available_bandengan(self): for product in self: - qty_available = product.qty_incoming_bandengan + product.qty_onhand_bandengan - product.qty_outgoing_bandengan + qty_available = product.qty_incoming_bandengan + product.qty_onhand_bandengan - product.qty_outgoing_bandengan - product.qty_outgoing_mo_bandengan product.qty_available_bandengan = qty_available or 0 def _get_qty_free_bandengan(self): @@ -1334,6 +1346,7 @@ class ProductProduct(models.Model): else: return super().write(vals) + class OutstandingMove(models.Model): _name = 'v.move.outstanding' _auto = False @@ -1345,6 +1358,7 @@ class OutstandingMove(models.Model): qty_need = fields.Float(string='Qty Need', help='Qty yang akan outgoing / incoming') location_id = fields.Many2one('stock.location', string='Location', help='Lokasi asal') location_dest_id = fields.Many2one('stock.location', string='Location To', help='Lokasi tujuan') + mo_id = fields.Many2one('mrp.production', string='Manufacturing Order') def init(self): # where clause 'state in' follow the origin of outgoing and incoming odoo @@ -1353,7 +1367,8 @@ class OutstandingMove(models.Model): CREATE OR REPLACE VIEW %s AS select sm.id, sm.reference, sm.product_id, sm.product_uom_qty as qty_need, - sm.location_id, sm.location_dest_id + sm.location_id, sm.location_dest_id, + sm.raw_material_production_id as mo_id from stock_move sm where 1=1 and sm.state in( -- cgit v1.2.3 From dbf09bbf792809e84d2d0330a992e42b3a5c6994 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Fri, 23 May 2025 09:38:02 +0700 Subject: Revert "Merge branch 'odoo-backup' of https://bitbucket.org/altafixco/indoteknik-addons into odoo-backup" This reverts commit 43313db30da73b87843425c01c723f66ee982886, reversing changes made to f6f59e660af6c4229ada54f7313d68867df1ba15. --- indoteknik_custom/models/product_template.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indoteknik_custom/models/product_template.py') diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index 89392033..17805c6c 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -870,9 +870,9 @@ class ProductTemplate(models.Model): record.message_post(body=f"Updated:") # log changes to product variants - # variant_message = f"Updated:" - # for variant in record.product_variant_ids: - # variant.message_post(body=variant_message) + variant_message = f"Updated:" + for variant in record.product_variant_ids: + variant.message_post(body=variant_message) # simpan data lama dan log perubahan field def write(self, vals): -- cgit v1.2.3 From 019bba2a3ff2ed08f53200df02c0638ddabbbe22 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Fri, 23 May 2025 11:16:30 +0700 Subject: bf outgoing with hold qty and change formula of reordering rule --- indoteknik_custom/models/product_template.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'indoteknik_custom/models/product_template.py') diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index 34b8fd2c..c62ca63e 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -1116,7 +1116,8 @@ class ProductProduct(models.Model): domain=[ ('product_id', '=', product.id), ('location_id', 'in', [57, 83]), - ('mo_id', '=', False) + ('mo_id', '=', False), + ('hold_outgoing', '=', False) ], fields=['qty_need'], groupby=[] @@ -1359,6 +1360,7 @@ class OutstandingMove(models.Model): location_id = fields.Many2one('stock.location', string='Location', help='Lokasi asal') location_dest_id = fields.Many2one('stock.location', string='Location To', help='Lokasi tujuan') mo_id = fields.Many2one('mrp.production', string='Manufacturing Order') + hold_outgoing = fields.Boolean(string='Hold Outgoing') def init(self): # where clause 'state in' follow the origin of outgoing and incoming odoo @@ -1368,8 +1370,11 @@ class OutstandingMove(models.Model): select sm.id, sm.reference, sm.product_id, sm.product_uom_qty as qty_need, sm.location_id, sm.location_dest_id, - sm.raw_material_production_id as mo_id + sm.raw_material_production_id as mo_id, + so.hold_outgoing from stock_move sm + left join procurement_group pg on pg.id = sm.group_id + left join sale_order so on so.id = pg.sale_id where 1=1 and sm.state in( 'waiting', -- cgit v1.2.3