-
Notifications
You must be signed in to change notification settings - Fork 0
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
[18.0][MIG] stock_product_variant_mto: Migration to 18.0 #1
base: 18.0
Are you sure you want to change the base?
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.
eb0843c
to
8619cbe
Compare
self.assertVariantsMTO(pens) | ||
# Disable mto route for black_pen | ||
self.toggle_is_mto(black_pen) | ||
self.assertVariantsNotMTO(black_pen) | ||
self.assertVariantsMTO(blue_pen | green_pen | red_pen) | ||
# Disable mto route on the template, reset is_mto on variants | ||
self.remove_route(pen_template, self.mto_route) | ||
with self.assertLogs(level="WARNING"): |
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 is recommended to explicitly add loggers to avoid error logs from other locations being missed.
@@ -24,14 +26,16 @@ def test_variants_mto(self): | |||
self.assertVariantsMTO(black_pen | blue_pen) | |||
self.assertVariantsNotMTO(red_pen | green_pen) | |||
# Now enable the mto route for the template, all variants get is_mto = True | |||
self.add_route(pen_template, self.mto_route) | |||
with self.assertLogs(level="WARNING"): |
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.
Same here
@@ -44,7 +48,8 @@ def test_template_routes_updated(self): | |||
black_pen = self.black_pen | |||
self.assertVariantsNotMTO(pens) | |||
# If template is set to MTO, all variants are updated | |||
self.add_route(pen_template, self.mto_route) | |||
with self.assertLogs(level="WARNING"): |
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.
Same here
# Enable mto route on the template, raise warning as is_mto is reset on variants | ||
with self.assertLogs(onchange_logger) as log: | ||
with self.assertLogs(level="WARNING") as log_catcher: |
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.
Same here
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.
Same in many places too 😉
b1cc181
to
c44fab9
Compare
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.
LG overall,
Small change:
# Enable unrelated route does not raise warning nor reset | ||
random_route = self.mto_route.create({"name": "loutourout de la vit"}) | ||
with self.assertLogs(onchange_logger) as log: | ||
with self.assertLogs("odoo.tests.form.onchange") as log_catcher: |
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.
odoo.tests.form.onchange
is reused many times. Optimize it by naming the variable eg onchange_logger
4889262
to
d557475
Compare
d557475
to
bbc05c8
Compare
bbc05c8
to
5e0cc07
Compare
route_ids
stored=True
because this code made errorNon-stored field product.product.route_ids cannot be searched.