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: allow moves merge #1834

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from
Open
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
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't be restrict_cancel_if_printed set to true.
Otherwise it will always call super._action_cancel?

Suggested change
self.picking.printed = True
self.picking_type.restrict_cancel_if_printed = True
self.picking.printed = True

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is a default=True, so should be the case

self.picking.move_ids.quantity_done = 10
self.picking.button_validate()
Loading