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_available_to_promise_release: normal outgoing moves are mergeable #937

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
9 changes: 4 additions & 5 deletions stock_available_to_promise_release/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ class StockMove(models.Model):

@api.depends("need_release", "rule_id", "rule_id.available_to_promise_defer_pull")
def _compute_unrelease_allowed(self):
user_is_allowed = self.env.user.has_group("stock.group_stock_user")
for move in self:
unrelease_allowed = move._is_unreleaseable()
unrelease_allowed = user_is_allowed and move._is_unreleaseable()
if unrelease_allowed:
iterator = move._get_chained_moves_iterator("move_orig_ids")
next(iterator) # skip the current move
Expand All @@ -79,10 +80,8 @@ def _is_unreleaseable(self):
_is_unrelease_allowed_on_origin_moves.
"""
self.ensure_one()
user_is_allowed = self.env.user.has_group("stock.group_stock_user")
return (
user_is_allowed
and not self.need_release
not self.need_release
and self.state not in ("done", "cancel")
and self.picking_type_id.code == "outgoing"
and self.rule_id.available_to_promise_defer_pull
Expand Down Expand Up @@ -787,7 +786,7 @@ def write(self, vals):
def _is_mergeable(self):
self.ensure_one()
return self.state not in ("done", "cancel") and (
self.picking_type_id.code != "outgoing" or self.unrelease_allowed
not self._is_unreleaseable() or self.unrelease_allowed
)

def _update_candidate_moves_list(self, candidate_moves):
Expand Down
14 changes: 14 additions & 0 deletions stock_available_to_promise_release/tests/test_merge_moves.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,17 @@ def test_unrelease_at_move_merge_merged(self):
self.assertEqual(1, len(move))
self.assertEqual(2 + original_qty_1 + original_qty_2, move.product_uom_qty)
self.assertEqual(2, move.move_line_ids.qty_done)

def test_default_merge(self):
# check that the merge is still working when the available_to_promise_defer_pull
# is False
self.wh.delivery_route_id.write(
{
"available_to_promise_defer_pull": False,
}
)
original_qty = self.shipping1.move_ids.product_uom_qty
# run a new procurement for the same product in the shipment 1
self._procure(2)
self.assertEqual(1, len(self.shipping1.move_ids))
self.assertEqual(original_qty + 2, self.shipping1.move_ids.product_uom_qty)
Loading