[16.0][FIX] stock_full_location_reservation: Do not unlink full location reservation moves on cancel#1194
Open
lmignon wants to merge 6 commits into
Open
Conversation
Contributor
|
Hi @mt-software-de, |
Author
b0dec94 to
d9a10b3
Compare
jbaudoux
reviewed
Jun 23, 2026
jbaudoux
reviewed
Jun 23, 2026
jbaudoux
approved these changes
Jun 23, 2026
3 tasks
d9a10b3 to
bd59ad3
Compare
mt-software-de
suggested changes
Jun 23, 2026
Comment on lines
+47
to
+86
| if not strict: | ||
| reservable_qties = self._get_full_location_reservable_qties( | ||
| package_only=package_only | ||
| ) | ||
| for line in self.exists(): | ||
| location = line.location_id | ||
| package = line.package_id | ||
| qties = reservable_qties.get(location, {}).get(package, {}) | ||
| if not qties: | ||
| continue | ||
| for product, qty in qties.items(): | ||
| moves_to_assign_ids.append( | ||
| line.move_id._full_location_reservation_create_move( | ||
| product, qty, location, package | ||
| ).id | ||
| ) | ||
| reservable_qties[location].pop(package) | ||
|
|
||
| else: | ||
| # Use Odoo core mechanism | ||
| Quant = self.env["stock.quant"] | ||
|
|
||
| for line in self.exists(): # Move line should have been deleted | ||
| quants = Quant._gather( | ||
| line.product_id, | ||
| line.location_id, | ||
| lot_id=line.lot_id, | ||
| package_id=line.package_id, | ||
| owner_id=line.owner_id, | ||
| strict=strict, | ||
| ) | ||
| reservable_qties[location].pop(package) | ||
| if not quants: | ||
| continue | ||
|
|
||
| total_quantity = 0.0 | ||
| for quant in quants: | ||
| total_quantity += quant.available_quantity | ||
| # We let the core mechanism occur that will reserve | ||
| # the needed quants | ||
| line.reserved_uom_qty += total_quantity |
There was a problem hiding this comment.
Can we maybe add a assert? Because strict=True and package_only=True together will not work.
Or could we change it to one argument. Like reservation_source or reservation_rule.
Which could be package, strict and product (@jbaudoux requested implementation)
As in some flows we need to limit the full reservation to the move line characteristics (lot, package, owner), add a strict mode that will use the Odoo core mechanism to gather the needed quant(ities)
Replace the 'strict' and 'package_only' parameters with a new reservation_mode parameter that can be set to "strict", "package" . The default behavior is the same as before but it ensures that the reservation mode is unique and can be extended in the future with new modes.
bd59ad3 to
7740e79
Compare
Author
|
@mt-software-de I implemented your requested changes can you update your review? |
…uct" Added a new reservation_mode "product" to the stock_full_location_reservation module. This mode allows for reserving all the same product at location, regardless of the package or lot.
…servation moves on cancel The module stock_full_location_reservation has a feature that creates a new move for full location reservation when a move is partially reserved. However, when the original move is canceled, the new move is also unlinked, which can cause issues if the new move is still needed for other operations. This commit modifies the behavior of the module to prevent the unlinking of full location reservation moves when the original move is canceled. Instead, the deletion of the move is deferred until the end of the transaction, allowing other operations to complete without losing the move.
7740e79 to
b1d778a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The module stock_full_location_reservation has a feature that creates a
new move for full location reservation when a move is partially reserved.
However, when the original move is canceled, the new move is also unlinked,
which can cause issues if the new move is still needed for other operations.
This commit modifies the behavior of the module to prevent the unlinking of
full location reservation moves when the original move is canceled. Instead,
the deletion of the move is deferred until the end of the transaction,
allowing other operations to complete without losing the move.
This is a partial rewrite of mt-software-de#6