Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][FIX] stock_picking_restrict_cancel_printed: fix no backorder #1817

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
Loading