-
-
Notifications
You must be signed in to change notification settings - Fork 720
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
[15.0][MIG]stock_available_unreserved #1340
[15.0][MIG]stock_available_unreserved #1340
Conversation
* [ADD] new module 'stock_available_unreserved'
_product_available() method is computed only once by location
Read quants without lang into the context to avoid sql join on ir.translations Iter on product with prefetch_fields=False and lang='' to avoid reading useless column ad join on ir.translations
The computation of the unreserved available amount using the StockQuant._get_available_quantity was wrong as soon as more than one quant was found for the same product. It can easily happen when you have sublocations and a quant in each location. The reason is that the algorithm was: 1. searching for all the quants for a given product 2. calling StockQuant._get_available_quantity for each quant 3. _get_available_quantity is an @api.model method, which itself will search for all quants for the product and the given location and children Which means that if you have these locations: Stock Stock > Bin A Stock > Bin B And these quants: 1. Product: Product A Location: Bin A Quantity: 60 Reserved: 0 2. Product: Product A Location: Bin B Quantity: 10 Reserved: 0 Instead of 70, the result was 140. (One loop for each quant, each loop recomputing the total quantity in _get_available_quantity, all summed togethed, for each new quant, an additional sum would be added). Ultimately, the _get_available_quantity method does the sum of (quantity - quantity reserved). This commit uses the same logic than the 10.0 branch, it finds the quants contextually using ProductProduct._get_domain_locations and get the available quantity as the sum of (quantity - quantity reserved). We can't really use StockQuant._get_available_quantity because this one expects a location, while here we don't necessarily know it. I removed _product_available_not_res_hook which seems to have no purpose, it does not receive the result of the computation and its own result is unused.
…not_reserved compute method in order to update the quantity.
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: stock-logistics-warehouse-12.0/stock-logistics-warehouse-12.0-stock_available_unreserved Translate-URL: https://translation.odoo-community.org/projects/stock-logistics-warehouse-12-0/stock-logistics-warehouse-12-0-stock_available_unreserved/
Currently translated at 38.5% (5 of 13 strings) Translation: stock-logistics-warehouse-12.0/stock-logistics-warehouse-12.0-stock_available_unreserved Translate-URL: https://translation.odoo-community.org/projects/stock-logistics-warehouse-12-0/stock-logistics-warehouse-12-0-stock_available_unreserved/zh_CN/
Currently translated at 100.0% (13 of 13 strings) Translation: stock-logistics-warehouse-12.0/stock-logistics-warehouse-12.0-stock_available_unreserved Translate-URL: https://translation.odoo-community.org/projects/stock-logistics-warehouse-12-0/stock-logistics-warehouse-12-0-stock_available_unreserved/es/
* update author's name after recent rebranding of Eficent to ForgeFlow. * change license to lgpl as agreed by the authors. * update readme to new format.
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: stock-logistics-warehouse-12.0/stock-logistics-warehouse-12.0-stock_available_unreserved Translate-URL: https://translation.odoo-community.org/projects/stock-logistics-warehouse-12-0/stock-logistics-warehouse-12-0-stock_available_unreserved/
Standard migration. Also some copyrights are removed because they were added by mistake in the fist place (copy+paste issues ;) )
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: stock-logistics-warehouse-13.0/stock-logistics-warehouse-13.0-stock_available_unreserved Translate-URL: https://translation.odoo-community.org/projects/stock-logistics-warehouse-13-0/stock-logistics-warehouse-13-0-stock_available_unreserved/
Currently translated at 92.3% (12 of 13 strings) Translation: stock-logistics-warehouse-14.0/stock-logistics-warehouse-14.0-stock_available_unreserved Translate-URL: https://translation.odoo-community.org/projects/stock-logistics-warehouse-14-0/stock-logistics-warehouse-14-0-stock_available_unreserved/fr/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
1304c64
to
aa1694c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functional tests 👍
@pedrobaeza could we merge this module? |
Merging trusting on the reviewers: /ocabot merge nobump |
What a great day to merge this nice PR. Let's do it! |
Congratulations, your PR was merged at 3b09438. Thanks a lot for contributing to OCA. ❤️ |
Standard migration to version 15.0.
@AaronHForgeFlow @mariadforgeflow