Skip to content

Commit

Permalink
[FIX] sale_order_line_cancel: Restore some features
Browse files Browse the repository at this point in the history
Allows to check the cancellation on sale order line level

Include normal sales (not locked)
  • Loading branch information
rousseldenis committed May 16, 2024
1 parent 8e74d07 commit 483041b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 4 additions & 1 deletion sale_order_line_cancel/models/sale_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def _compute_can_cancel_remaining_qty(self):
rec.product_qty_remains_to_deliver, 0, precision_digits=precision
)
== 1
and rec.state == "done"
and rec.state in ("sale", "done")
and rec.move_ids
)

Expand All @@ -48,3 +48,6 @@ def _compute_product_qty_remains_to_deliver(self):
line.product_uom_qty - line.qty_delivered - line.product_qty_canceled
)
line.product_qty_remains_to_deliver = remaining_to_deliver

def _check_moves_to_cancel(self, moves):
"""override this method to add checks before cancel"""
5 changes: 1 addition & 4 deletions sale_order_line_cancel/wizards/sale_order_line_cancel.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,12 @@ def _get_sale_order_line(self):
def _get_moves_to_cancel(self, line):
return line.move_ids.filtered(lambda m: m.state not in ("done", "cancel"))

def _check_moves_to_cancel(self, moves):
"""override this method to add checks before cancel"""

def cancel_remaining_qty(self):
line = self._get_sale_order_line()
if not line.can_cancel_remaining_qty:
return False
cancel_moves = self._get_moves_to_cancel(line)
self._check_moves_to_cancel(cancel_moves)
line._check_moves_to_cancel(cancel_moves)
cancel_moves._action_cancel()
line.order_id.message_post(
body=_(
Expand Down

0 comments on commit 483041b

Please sign in to comment.