Skip to content

[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
OCA:16.0from
acsone:16.0-stock_full_reservation-no_unlink_on_cancel-lmi
Open

[16.0][FIX] stock_full_location_reservation: Do not unlink full location reservation moves on cancel#1194
lmignon wants to merge 6 commits into
OCA:16.0from
acsone:16.0-stock_full_reservation-no_unlink_on_cancel-lmi

Conversation

@lmignon

@lmignon lmignon commented Jun 22, 2026

Copy link
Copy Markdown

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.

  • includes 1193

This is a partial rewrite of mt-software-de#6

@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hi @mt-software-de,
some modules you are maintaining are being modified, check this out!

@OCA-git-bot OCA-git-bot added series:16.0 mod:stock_full_location_reservation Module stock_full_location_reservation labels Jun 22, 2026
@lmignon

lmignon commented Jun 22, 2026

Copy link
Copy Markdown
Author

@rousseldenis @jbaudoux

@lmignon lmignon force-pushed the 16.0-stock_full_reservation-no_unlink_on_cancel-lmi branch from b0dec94 to d9a10b3 Compare June 23, 2026 06:22
Comment thread stock_full_location_reservation/models/stock_move.py Outdated
Comment thread stock_full_location_reservation/models/stock_move.py Outdated
Comment thread stock_full_location_reservation/models/stock_move_line.py Outdated
Comment thread stock_full_location_reservation/models/stock_move.py
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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)

lmignon added 3 commits June 24, 2026 09:50
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.
@lmignon lmignon force-pushed the 16.0-stock_full_reservation-no_unlink_on_cancel-lmi branch from bd59ad3 to 7740e79 Compare June 24, 2026 07:54
@lmignon

lmignon commented Jun 24, 2026

Copy link
Copy Markdown
Author

@mt-software-de I implemented your requested changes can you update your review?
@jbaudoux I added a reservation_mode for product only

lmignon added 3 commits June 24, 2026 09:59
…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.
@lmignon lmignon force-pushed the 16.0-stock_full_reservation-no_unlink_on_cancel-lmi branch from 7740e79 to b1d778a Compare June 24, 2026 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:stock_full_location_reservation Module stock_full_location_reservation series:16.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants