Skip to content

Commit

Permalink
stock_picking_restrict_cancel_printed: fix no backorder
Browse files Browse the repository at this point in the history
Allow to validate a partial picking when the backorder policy is set to never
  • Loading branch information
jbaudoux committed Jan 3, 2025
1 parent fa2bd36 commit de44acc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions stock_picking_restrict_cancel_printed/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ class StockMove(models.Model):
_inherit = "stock.move"

def _action_cancel(self):
# 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()
for move in self:
if (
move.picking_id.printed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def setUpClass(cls):
{
"name": "Test move",
"product_id": cls.product.id,
"product_uom_qty": 1,
"product_uom_qty": 3,
"location_id": cls.env.ref("stock.stock_location_stock").id,
"location_dest_id": cls.env.ref(
"stock.stock_location_customers"
Expand Down Expand Up @@ -58,3 +58,10 @@ def test_stock_move_restrict_cancel_printed_disabled(self):
self.picking_type.restrict_cancel_if_printed = False
self.picking.printed = True
self.picking.move_ids._action_cancel()

def test_stock_move_restrict_cancel_printed_enabled_nobackorder(self):
"""Check a picking partially processed can be validated when no backorder are created"""
self.picking.printed = True
self.picking.move_ids.quantity_done = 1
self.picking_type.create_backorder = "never"
self.picking.button_validate()

0 comments on commit de44acc

Please sign in to comment.