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
MIG stock_mts_mto_rule to 12.0 #586
Conversation
… procurement rules to handle the mts+mto scenario
Add explanation for finding this setting
Conforms to the latest README template: bugtracker, runbot etc. Fixes bugtracker URL on some modules. States OCA as maintainer, removes other contributors from the 'Maintainer' section.
…en warehouse is two/three steps delivery propagate move by mts-mto in pick/pack/out
OCA Transbot updated translations from Transifex
…least another procurement
There's a traceback when renaming warehouse code (without renaming warehouse name), as name argument is False.
OCA Transbot updated translations from Transifex OCA Transbot updated translations from Transifex
This method is called from the write() method the one how support multiple records an api.multi method. I was making some test when I tried to activate the mto+mts option for multiple warehouse and the next error appears: ``ValueError: Expected singleton`` In order to fix this error I only added a loop to manage the multiple registers.
OCA Transbot updated translations from Transifex
Hey @jaredkipe, thank you for your Pull Request. It looks like some users haven't signed our Contributor License Agreement, yet.
Appreciation of efforts, |
We've just pulled this branch. I did a quick functional test on it as well as ran all of the tests. Everything seems to pass with flying colors. 👍 |
@manney thank you! Anyone else interested in trying it, and potentially other beta branches like |
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.
Code review.
stock_mts_mto_rule/__init__.py
Outdated
@@ -0,0 +1 @@ | |||
from . import model |
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.
stock_mts_mto_rule/__manifest__.py
Outdated
{'name': 'Stock MTS+MTO Rule', | ||
'version': '12.0.1.0.0', | ||
'author': 'Hibou Corp.,Akretion,Odoo Community Association (OCA)', | ||
'website': 'http://www.akretion.com', |
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.
Could you follow OCA conventions for manifest (website, missing entires) ?
https://github.com/OCA/maintainer-tools/blob/master/template/module/__manifest__.py
stock_mts_mto_rule/__manifest__.py
Outdated
'summary': 'Add a MTS+MTO route', | ||
'depends': ['stock', | ||
], | ||
'demo': [], |
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.
Please remove void one
if not rule.mts_rule_id or not rule.mto_rule_id: | ||
msg = _('No MTS or MTO rule configured on procurement ' | ||
'rule: %s!') % (rule.name, ) | ||
raise UserError(msg) |
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.
Constrains must raise ValidationError
msg = _('Inconsistency between the source locations of ' | ||
'the mts and mto rules linked to the procurement ' | ||
'rule: %s! It should be the same.') % (rule.name,) | ||
raise UserError(msg) |
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.
Constrains must raise ValidationError
qty_available = product.uom_id._compute_quantity( | ||
virtual_available, product_uom) | ||
|
||
if qty_available > 0: |
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.
You should use float_compare
needed_qty = self.get_mto_qty_to_order(product_id, product_qty, | ||
product_uom, values) | ||
|
||
if needed_qty == 0.0: |
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.
You should use float_is_zero
getattr(self.mts_rule_id, '_run_%s' % self.mts_rule_id.action)( | ||
product_id, product_qty, product_uom, location_id, name, | ||
origin, values) | ||
elif needed_qty == product_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.
You should use float_compare
@@ -0,0 +1,95 @@ | |||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | |||
|
|||
from odoo import models, fields |
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.
from odoo import models, fields | |
from odoo import fields, models, _ |
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.
Thanks for the migration!
I made some minor comments
Otherwise I did functional tests and it seems to work as expected.
@@ -0,0 +1,92 @@ | |||
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png |
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.
It would be nice to split the readme, like explain here : https://github.com/OCA/maintainer-tools/wiki/Migration-to-version-12.0
------------ | ||
|
||
* Florian da Costa <florian.dacosta@akretion.com> | ||
|
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.
You can add yourself in the contributor list, but not in the authors
stock_mts_mto_rule/__manifest__.py
Outdated
|
||
{'name': 'Stock MTS+MTO Rule', | ||
'version': '12.0.1.0.0', | ||
'author': 'Hibou Corp.,Akretion,Odoo Community Association (OCA)', |
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.
You should put yourself in the contributor and not in the authors
@jaredkipe Do you plan to attend comments? |
nothing specific. at this moment he will give a git chada and honestly say little wien. |
Ugh, didn't understand... |
Now that Odoo has merged in odoo/odoo#33288 , I have removed the patch and re-worked the test. Otherwise I believe I have addressed everyone's concerns other than splitting the README into multiple files. |
@jaredkipe Just lint errors and LGTM! |
Should be good now, feel free to squash as there are now a couple of simple 'fix' commits that don't really help. |
Hi Jared, I cannot just squash your four migration commits during merging. Could you do it ? |
Major changes to the way Warehouses update their routes/rules and self heal. Improved rule code to use `float_compare` and `float_is_zero`.
9d37a0b
to
aadbde3
Compare
All done with that, the only major difference is that it now thinks the |
Hi Folks, any idea when this PR is likely to be approved? we do have a customer waiting on this - blocking issue for him & his business. Would be very much appreciated, thanks a lot in advance! :-) |
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.
Code review. LGTM
This PR has the |
/ocabot merge |
Rebased to 12.0-ocabot-merge-pr-586-by-rousseldenis-bump-no, awaiting test results. |
Merged at 638aa1c. 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 on the main branch. |
There were major changes to the way Warehouses maintain their routes/rules and self heal in 12.0
This necessitated large changes to
models/stock_warehouse.py
and some changes to test expectations.In general, I read through the new Odoo code to get a feel for how they are updating and healing routes, then I applied the same methodology to the refactor work. I didn't really comment these methods as a search through purchase, mrp, stock for the same method names will turn up very similar looking code (that is also not commented).
Some not so great things...
In the model
stock.warehouse
Odoo provides a shim for an old method namedget_all_routes_for_wh
that is now effectively named_get_all_routes
. However, in purchase_stock module, they incorrectly call the parent method that isn't actually the method being called.This can lead to infinite loops, so ultimately I ended up just resorting to the same 'shim' approach that Odoo took.