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

[13.0][MIG] stock_available_unreserved #810

Merged
merged 24 commits into from
Dec 30, 2019

Conversation

LoisRForgeFlow
Copy link
Contributor

Standard migration to v13.

@ForgeFlow

JordiBForgeFlow and others added 23 commits December 20, 2019 12:34
* [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/
@LoisRForgeFlow LoisRForgeFlow added this to the 13.0 milestone Dec 20, 2019
@oca-clabot
Copy link

Hey @LoisRForgeFlow, thank you for your Pull Request.

It looks like some users haven't signed our Contributor License Agreement, yet.
You can read and sign our full Contributor License Agreement here: http://odoo-community.org/page/cla
Here is a list of the users:

Appreciation of efforts,
OCA CLAbot

@OCA-git-bot

This comment has been minimized.

Standard migration. Also some copyrights are removed because they were added by mistake in the fist place (copy+paste issues ;) )
@LoisRForgeFlow LoisRForgeFlow force-pushed the 13.0-mig-stock_available_unreserved branch from fecc8a0 to 9fecf39 Compare December 20, 2019 13:05
@rousseldenis

This comment has been minimized.

Copy link

@AdriaGForgeFlow AdriaGForgeFlow left a comment

Choose a reason for hiding this comment

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

Functional review 👍

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.

👍 Code review LGTM

@LoisRForgeFlow
Copy link
Contributor Author

/ocabot merge

@OCA-git-bot
Copy link
Contributor

Hey, thanks for contributing! Proceeding to merge this for you.
Prepared branch 13.0-ocabot-merge-pr-810-by-LoisRForgeFlow-bump-no, awaiting test results.

OCA-git-bot added a commit that referenced this pull request Dec 30, 2019
Signed-off-by LoisRForgeFlow
@OCA-git-bot OCA-git-bot merged commit 9fecf39 into OCA:13.0 Dec 30, 2019
@OCA-git-bot
Copy link
Contributor

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

@LoisRForgeFlow LoisRForgeFlow deleted the 13.0-mig-stock_available_unreserved branch December 30, 2019 15:47
@OCA-git-bot OCA-git-bot mentioned this pull request Jan 3, 2020
54 tasks
@kos94ok-3D
Copy link
Contributor

kos94ok-3D commented Jul 7, 2020

Hi, @LoisRForgeFlow.
Is it in a stock module now or I miss something?

@LoisRForgeFlow
Copy link
Contributor Author

@kos94ok-3D I cannot find it, could you point me the code?

@kos94ok-3D
Copy link
Contributor

@jjscarafia
Copy link

@kos94ok-3D @LoisRForgeFlow
yes, is seems Odoo has the same field as @kos94ok-3D said (free_qty field) but it's only on product.product (not in product.template)
perhaps for v14/master we could try a PR to add free_qty also on pt and then we could get rid of this module

CarlosRoca13 pushed a commit to Tecnativa/stock-logistics-warehouse that referenced this pull request Aug 16, 2021
Signed-off-by LoisRForgeFlow
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.

None yet