-
-
Notifications
You must be signed in to change notification settings - Fork 724
[18.0][MIG] stock_product_variant_mto: Migration to 18.0 #1819
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
Conversation
Define route_ids as computed on the product variant, in order to reuse route_ids from its template and add or remove MTO route according to the setting on the variant. In case MTO route is changed on the template, it must reset any variant specific setting.
4889262
to
d557475
Compare
/ocabot migration stock_product_variant_mto |
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 mig.
However, IMO we should keep migration commit to a minimum in order to highlight the required changes and avoid rewriting for cosmetic changes or fixing typos
compute="_compute_route_ids", | ||
domain="[('product_selectable', '=', True)]", | ||
store=False, | ||
store=True, |
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.
Can't we define a search function instead?
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.
I think not, because compute can track when is_mto
was changed
product.route_ids = product.product_tmpl_id.route_ids + mto_route | ||
continue | ||
product.route_ids = product.product_tmpl_id.route_ids | ||
new_route_ids = product.product_tmpl_id.route_ids |
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.
Nitpicking a little, but this is a recordset, not a list of ids. Also these ain't new routes but the routes from the template. I would call this variable something like template_routes
or product_routes
.
However, all this rewriting does not bring anything in the context of module migration as the conditions are the same as before... IMO it only adds more work for the reviewer...
templates_mto_added = template_not_mto_before & templates_mto_after | ||
templates_mto_removed = (self - template_not_mto_before) & ( | ||
self - templates_mto_after | ||
) | ||
( | ||
templates_mto_added = templates_not_mto_before & templates_mto_after | ||
templates_mto_removed = self - templates_mto_after - templates_not_mto_before | ||
|
||
affected_product_variants = ( | ||
templates_mto_added | templates_mto_removed | ||
).product_variant_ids._compute_is_mto() | ||
).product_variant_ids | ||
if affected_product_variants: | ||
affected_product_variants._compute_is_mto() |
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.
Basically these are pure cosmetic change that will only obfuscate the original contribution when blaming the code, I don't think it must be part of a migration.
d557475
to
bbc05c8
Compare
@chaule97 @grindtildeath @jbaudoux Maybe it should have been great to merge this one with that one : https://github.com/OCA/product-attribute/tree/16.0/product_route_mto |
This module allows to define if a product variant can use the Make To | ||
Order route without any dependency on its template routes settings. |
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.
Add a big warning that the routes are moved from product template to product product !
Certainly NOT. However, this module should be in product-attribute repo and I would rename it |
bbc05c8
to
5e0cc07
Compare
Do you or I move it? |
Close this PR and open a new one on product attribute |
Hello everyone, I move it to OCA/product-attribute#1879, please review it in new PR, thanks |
route_ids
stored=True
because this code made errorNon-stored field product.product.route_ids cannot be searched.