Skip to content

Commit

Permalink
[FIX] mrp: run_pull in store after manufacturing more generic
Browse files Browse the repository at this point in the history
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#161690

X-original-commit: f82a0f2
Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
  • Loading branch information
amoyaux committed Apr 15, 2024
1 parent 50e55bd commit 5c7be00
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions addons/mrp/models/stock_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,16 @@ def _run_pull(self, procurements):
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:
Expand Down

0 comments on commit 5c7be00

Please sign in to comment.