[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) <arm@odoo.com>
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
This commit is contained in:
Arnold Moyaux
2024-04-15 09:10:17 +00:00
parent 50e55bd8dd
commit 5c7be00378
+6 -2
View File
@@ -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: