Skip to content

Commit

Permalink
stock_picking_restrict_cancel_printed: merge
Browse files Browse the repository at this point in the history
Support moves merge
  • Loading branch information
jbaudoux committed Jan 17, 2025
1 parent 61e6526 commit a1ff3c2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions stock_picking_restrict_cancel_printed/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@
class StockMove(models.Model):
_inherit = "stock.move"

def _merge_moves(self, merge_into=False):
# Merging moves will cancel the merged move. We need to allow this.
return super(
StockMove, self.with_context(disable_printed_check=True)
)._merge_moves(merge_into=merge_into)

def _action_cancel(self):
if self.env.context.get("disable_printed_check"):
return super()._action_cancel()
# if picking_type create_backorder is never, then move is canceled on action_done
if self.env.context.get("cancel_backorder"):
return super()._action_cancel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,13 @@ def test_stock_move_restrict_cancel_printed_enabled_nobackorder(self):
self.picking.move_ids.quantity_done = 1
self.picking_type.create_backorder = "never"
self.picking.button_validate()

def test_stock_move_restrict_cancel_printed_enabled_move_merge(self):
"""Check a picking processed in excess can be validated
This will trigger the creation of an extra move.
That extra gets merged and then canceled.
"""
self.picking.printed = True
self.picking.move_ids.quantity_done = 10
self.picking.button_validate()

0 comments on commit a1ff3c2

Please sign in to comment.