Skip to content

Commit

Permalink
[IMP] rma : propagate cancelation
Browse files Browse the repository at this point in the history
When canceling a rma order line, it will also cancel the previous (orig) steps.
Following steps (dest) can be managed with the propagate cancel option of the stock rules.
This commit also avoid canceling a whole picking which is problematic in case of the use of RMA groups
  • Loading branch information
florian-dacosta committed Aug 29, 2024
1 parent 334b86f commit 37b1b34
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions rma/models/rma_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,12 +692,21 @@ def check_cancel(self):
def action_rma_cancel(self):
for order in self:
order.check_cancel()
# cancel ongoing orig moves
# dest move cancelation can be managed with propagate_cancel option
# on stock rules.
moves = order.move_ids
to_cancel_orig_moves = self.env["stock.move"]
while moves:
moves = moves.move_orig_ids.filtered(
lambda m: m.state not in ("done", "cancel")
and m.picking_id
and not m.purchase_line_id
)
to_cancel_orig_moves |= moves
to_cancel_orig_moves._action_cancel()
order.write({"state": "canceled"})
order.move_ids._action_cancel()
shipments = order._get_in_pickings()
shipments |= order._get_out_pickings()
for ship in shipments:
ship.action_cancel()
return True

def _get_price_unit(self):
Expand Down

0 comments on commit 37b1b34

Please sign in to comment.