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
[12.0][stock_available_mrp] Migration + make compatible with other stock_available_immediately #644
Conversation
5f7d4c8
to
ace3a3e
Compare
) | ||
|
||
res[product.id]['potential_qty'] = potential_qty | ||
res[product.id]['immediately_usable_qty'] += potential_qty |
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.
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.
hello @sergio-teruel
Yes it is the behavior of the module, I did not change this.
The potential quantity is added to the immediately_usable_qty and it is intended.
@florian-dacosta I think you should take a look at what @Cedric-Pigeon has done in v10 : https://github.com/OCA/stock-logistics-warehouse/blob/10.0/stock_available/models/product_template.py |
Please @florian-dacosta take a quick read also in #611 Thank you for this great contribution! 😄 |
@rousseldenis @rafaelbn Thanks for the pointer. |
@rousseldenis Actually, both PR you pointed concern more the stock_available module, which has already been migrated to 12, and wich seems to contains all modifications. |
bom_id = fields.Many2one( | ||
'mrp.bom', | ||
compute='_compute_bom_id', | ||
string='Bill of Materials' |
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.
Change this string due to:
2019-08-16 15:08:49,323 175 WARNING openerp_test odoo.addons.base.models.ir_model: Two fields (bom_ids, bom_id) of product.product() have the same label: Bill of Materials.
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.
Done!
Hey @florian-dacosta, thank you for your Pull Request. It looks like some users haven't signed our Contributor License Agreement, yet.
Appreciation of efforts, |
/ocabot merge |
What a great day to merge this nice PR. Let's do it! |
@pedrobaeza The merge process could not be finalized, because command
|
Compute potential quantities for both product templates and variants. To keep the code simple, only the biggest potential of any single variant is accounted for in the template's potential. Take all levels of phantom BoM into account, respects validity dates etc. thanks to the use of the standard method _bom_explode, as suggested by @gdgellatly in OCA#5 (comment) Improve tests, rewritten in python. Adhere to new file/manifest/README conventions. Simplify copyright headers
sudo is not required since mrp.bom are readable to groups with access to the qty_x fields on a product. Moreover using sudo to retrive the bom will ignore the company_id defined on the bom
Record rules used to not be checked on stock quants, but now they are since Odoo's commit 2fd14db (odoo/odoo@2fd14db). In our test we changed the company of the products and BoMs but we neglected that the stock was not attached to the right company, and that made the test fail. To fix that, make the test inventory for the right company. Since there is a little inconsistency in the demo data with a negative quantity of an unrelated product, use the `partial` filter for the inventories instead of the `none` filter, so that no wrong inventory lines are added automatically.
…ch field use to compute potential
…ew + small improvements
* mrp_bom.name has been deleted. * mrp_bom_line.type moved to mrp_bom.type. * Fix missing group_mrp_user issue. * Change versions
…recordset + Condition never statisfied
…of immediately usable qty
c242435
to
1312f68
Compare
/ocabot merge |
On my way to merge this fine PR! |
Congratulations, your PR was merged at 33e5d79. Thanks a lot for contributing to OCA. ❤️ PS: Don't worry if GitHub says there are unmerged commits: it is due to a rebase before merge. All commits of this PR have been merged into |
Hi, This PR has 2 commits.
First one is standard migration, second one try to solve a problem I have detected.
If I understand well, the purpose code in product_template.py that I removed (https://github.com/OCA/stock-logistics-warehouse/blob/11.0/stock_available_mrp/models/product_template.py#L14), was to be sure, in case a template with variants, that the immediately usable qty of our bom is the sum of all real planned qties of the variable (by default, virtual qty) + the potential quantity, which is the highest potential of its variants.
Indeed, we see in method
_compute_available_quantities_dict
of stock_available module : https://github.com/OCA/stock-logistics-warehouse/blob/12.0/stock_available/models/product_template.py#L29that the computed immediately_usable_qty of our template is the sum of all quantities of the variants, but, the quantities of the variant, already include the potential quantity !
See : https://github.com/OCA/stock-logistics-warehouse/blob/11.0/stock_available_mrp/models/product_product.py#L122
So, without this code (https://github.com/OCA/stock-logistics-warehouse/blob/11.0/stock_available_mrp/models/product_template.py#L14) we add in template qty_immediately_usable the potential qty of all variants even though we want only to count the highest potential qty of the variant...
Anyway, the problem is that it makes it incompatible with others modules like stock_available_immediately. (and maybe others).
Indeed, stock_available_immediately remove the incoming quantity from the virtual quantity.
But the patch I removed (stock_available_immediately) go from virtual quantity once more...
That's what I have tried to correct in my second commit. For this I need to modify the logic in stock_available.
(+ make impossible to have a negative potential quantity, because I guess it makes no sense...but this have nothing to do with the problem described!)
It seems to work fine and the test passes without any problem.
But any opinion is welcome. @lmignon @Cedric-Pigeon @rafaelbn @tschanzt @simahawk @grindtildeath