mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[FIX] rma: improve check on rule selection during procurement
Fixes #274 Thanks to @florian-dacosta for suggesting this approach.
This commit is contained in:
committed by
Florian da Costa
parent
6977529152
commit
2abf2f08d3
@@ -144,10 +144,8 @@ class RmaMakePicking(models.TransientModel):
|
||||
group = self.env["procurement.group"].create(pg_data)
|
||||
if picking_type == "incoming":
|
||||
qty = item.qty_to_receive
|
||||
force_rule_ids = item.line_id.in_route_id.rule_ids.ids
|
||||
else:
|
||||
qty = item.qty_to_deliver
|
||||
force_rule_ids = item.line_id.out_route_id.rule_ids.ids
|
||||
values = self._get_procurement_data(item, group, qty, picking_type)
|
||||
values = dict(values, rma_line_id=item.line_id, rma_id=item.line_id.rma_id)
|
||||
# create picking
|
||||
@@ -165,9 +163,11 @@ class RmaMakePicking(models.TransientModel):
|
||||
)
|
||||
|
||||
procurements.append(procurement)
|
||||
self.env["procurement.group"].with_context(
|
||||
rma_force_rule_ids=force_rule_ids
|
||||
).run(procurements)
|
||||
# Trigger a route check with a mutable in the context that can be
|
||||
# cleared after the first rule selection
|
||||
self.env["procurement.group"].with_context(rma_route_check=[True]).run(
|
||||
procurements
|
||||
)
|
||||
except UserError as error:
|
||||
errors.append(error.name)
|
||||
if errors:
|
||||
|
||||
Reference in New Issue
Block a user