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

[15.0][MIG]stock_available_unreserved #1340

Merged
merged 38 commits into from
Jan 28, 2022

Conversation

JoanMForgeFlow
Copy link
Contributor

Standard migration to version 15.0.
@AaronHForgeFlow @mariadforgeflow

JordiBForgeFlow and others added 30 commits December 21, 2021 11:57
* [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/
Copy link

@mariadforgeflow mariadforgeflow left a comment

Choose a reason for hiding this comment

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

LGTM!

@JoanMForgeFlow JoanMForgeFlow force-pushed the 15.0-mig-stock_available_unreserved branch from 1304c64 to aa1694c Compare December 22, 2021 07:27
Copy link
Contributor

@AaronHForgeFlow AaronHForgeFlow left a comment

Choose a reason for hiding this comment

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

Functional tests 👍

@JoanMForgeFlow
Copy link
Contributor Author

@pedrobaeza could we merge this module?

@pedrobaeza
Copy link
Member

Merging trusting on the reviewers:

/ocabot merge nobump
/ocabot migration stock_available_unreserved

@OCA-git-bot OCA-git-bot added this to the 15.0 milestone Jan 28, 2022
@OCA-git-bot OCA-git-bot mentioned this pull request Jan 28, 2022
80 tasks
@OCA-git-bot
Copy link
Contributor

What a great day to merge this nice PR. Let's do it!
Prepared branch 15.0-ocabot-merge-pr-1340-by-pedrobaeza-bump-nobump, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 98d0199 into OCA:15.0 Jan 28, 2022
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 3b09438. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.