From 5c7be00378523ea1b3364997ea1eebec7954a844 Mon Sep 17 00:00:00 2001 From: Arnold Moyaux Date: Fri, 22 Mar 2024 13:28:30 +0000 Subject: [PATCH] [FIX] mrp: run_pull in store after manufacturing more generic There is 2 issues with it: - People that want to use multiple picking type or multiple store after manufacturing locations. It's not possible since the equals is strict on the warehouse store after manufacturing picking type. - The procurement group always use the default manufacture picking type and ignore the picking type on the manufacture rule that will be use. This commit checks if the location is a child of the post production in order to create the procurement group. It would be an issue for people having multiple step in post prod. But it could be fix by using a subset of the warehouse post production location. Check if we have a manufacture rule with the same warehouse in the current route. It's not perfect but it could give a more accurate result than today. closes odoo/odoo#161690 X-original-commit: f82a0f2ea8f3c57bae915520f9e4a25b54b81ce4 Signed-off-by: Arnold Moyaux (arm) Signed-off-by: William Henrotin (whe) --- addons/mrp/models/stock_rule.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/mrp/models/stock_rule.py b/addons/mrp/models/stock_rule.py index 1397f3f21e2..9a34bc50480 100644 --- a/addons/mrp/models/stock_rule.py +++ b/addons/mrp/models/stock_rule.py @@ -118,12 +118,16 @@ class StockRule(models.Model): warehouse_id = rule.warehouse_id if not warehouse_id: warehouse_id = rule.location_dest_id.warehouse_id - if rule.picking_type_id == warehouse_id.sam_type_id: + if rule.picking_type_id == warehouse_id.sam_type_id or (warehouse_id.sam_loc_id and warehouse_id.sam_loc_id.parent_path in rule.location_src_id.parent_path): if float_compare(procurement.product_qty, 0, precision_rounding=procurement.product_uom.rounding) < 0: procurement.values['group_id'] = procurement.values['group_id'].stock_move_ids.filtered( lambda m: m.state not in ['done', 'cancel']).move_orig_ids.group_id[:1] continue - manu_type_id = warehouse_id.manu_type_id + manu_rule = rule.route_id.rule_ids.filtered(lambda r: r.action == 'manufacture' and r.warehouse_id == warehouse_id) + if manu_rule: + manu_type_id = manu_rule[0].picking_type_id + else: + manu_type_id = warehouse_id.manu_type_id if manu_type_id: name = manu_type_id.sequence_id.next_by_id() else: