Skip to content

Conversation

chaule97
Copy link
Owner

@chaule97 chaule97 commented Jan 2, 2025

mmequignon and others added 4 commits January 2, 2025 10:19
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.
@chaule97 chaule97 force-pushed the 18.0-mig-stock_product_variant_mto branch from eb0843c to 8619cbe Compare January 2, 2025 08:12
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"):

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.

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"):

Choose a reason for hiding this comment

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

Same here

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"):

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:

Choose a reason for hiding this comment

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

Same here

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 😉

@chaule97 chaule97 force-pushed the 18.0-mig-stock_product_variant_mto branch 2 times, most recently from b1cc181 to c44fab9 Compare January 6, 2025 04:50
@chaule97 chaule97 requested a review from thienvh332 January 6, 2025 04:52
Copy link

@thienvh332 thienvh332 left a 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:

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

@chaule97 chaule97 force-pushed the 18.0-mig-stock_product_variant_mto branch 3 times, most recently from 4889262 to d557475 Compare January 10, 2025 08:00
@chaule97 chaule97 force-pushed the 18.0-mig-stock_product_variant_mto branch from d557475 to bbc05c8 Compare February 5, 2025 04:24
@chaule97 chaule97 force-pushed the 18.0-mig-stock_product_variant_mto branch from bbc05c8 to 5e0cc07 Compare February 5, 2025 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants