[18][stock_reserve_rule][FIX] Make sure quant are really excluded from reservation if a quant_domain is set on the removal rule #31
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.
I was testing the module to solve the following use case :
On a location, I have some products inside some packages... and some other not belonging to any package.
My goal is to reserve only product not belonging to a package for a dedicated picking type.
Let's say I have, in stock/shelf1, 1 product A in a package PACK0001 and 1 product A (without package). ProductA/PACK0001 did enters the stock first so it would be taken first with default FIFO removal strategy.
I create a reserve rule for stock location with a removal rule on stock/shelf1 with a quant_domain
[('package_id', '=', False)](and default advanced removal strategy)If I create a picking with 1 stock move with product A / product_uom_qty = 1, then check the availability. The system does reserve 1 product A with the PACK0001 !
It actually depends on the original default strategy, but it is kind of random.
What happens is :
The system find only the quant product A/no pack (it filters out the quant product A / PACK0001) https://github.com/OCA/stock-logistics-reservation/blob/18.0/stock_reserve_rule/models/stock_move.py#L70
Then it will find it can reserve 1 qty in self1 because of our free eligible quant Product A/no pack : https://github.com/OCA/stock-logistics-reservation/blob/18.0/stock_reserve_rule/models/stock_move.py#L86
And then he will try to make the reservation on the location, but as it is not "strict", Odoo will search a quant, that may or not have a package, because at this time, he is now aware of the quant that are eligible https://github.com/OCA/stock-logistics-reservation/blob/18.0/stock_reserve_rule/models/stock_move.py#L95
So it takes the package quant (because it is the first one with default FIFO strategy)/
Unless I am missing something about the module/quant_domain utility, I guess this is a bug.
My fix consist in ignoring the quants that have been filtered out by our removal rule during the reservation process.
A review/opinion would be gratly appreciated @rousseldenis @jbaudoux @bizzappdev