Skip to content

Conversation

chaule97
Copy link
Contributor

@chaule97 chaule97 commented Feb 6, 2025

mmequignon and others added 4 commits February 6, 2025 10:02
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.
@jbaudoux
Copy link
Contributor

jbaudoux commented Feb 6, 2025

cc @mmequignon @grindtildeath

"stock.route",
compute="_compute_route_ids",
domain="[('product_selectable', '=', True)]",
store=True,
Copy link
Contributor

@grindtildeath grindtildeath Feb 6, 2025

Choose a reason for hiding this comment

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

IMO we do not want to store this field and must define a search function instead.

The goal with this field is to use the route_ids from the template - plus/minus the MTO route depending on the setting of the variant - when reading/searching on the product variant. By storing this, the route_ids from the template will not be used anymore, with the possibility to have inconsistencies between product and template as the product variant routes will not reflect anymore the routes from the template.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please point the open PR in v14 fixing this so that it can be ported once finished

Copy link
Contributor

@simahawk simahawk Apr 8, 2025

Choose a reason for hiding this comment

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

I agree.
@chaule97 can you please drop the store attribute and add a search function (if necessary)?
Just here, not on v14 for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have updated it, please review my new updates

Copy link
Contributor

@jbaudoux jbaudoux left a comment

Choose a reason for hiding this comment

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

Waiting fix on v14

@chaule97 chaule97 force-pushed the product-attribute-18.0-mig-product_variant_route_mto branch from 6871f14 to 6ec3dde Compare April 9, 2025 07:44
@simahawk simahawk requested review from grindtildeath and jbaudoux May 7, 2025 08:19
Copy link
Contributor

@grindtildeath grindtildeath left a comment

Choose a reason for hiding this comment

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

I guess we need a test on the search of route_ids 😬

def _search_route_ids(self, operator, value):
mto_route = self.env.ref("stock.route_warehouse0_mto", raise_if_not_found=False)
if not mto_route:
return [(0, "=", 1)] if operator in ("=", "in") else [(0, "=", 0)]
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ you need to check the value before returning such a domain.

If I search for something like [('route_ids, in, buy_route.id)]` I would expect to get the products where the buy route is defined and the MTO being archived or not should not have any influence.

Copy link
Contributor

@jbaudoux jbaudoux left a comment

Choose a reason for hiding this comment

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

There are several issues, i take it over here #1970

@simahawk simahawk closed this May 14, 2025
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.

5 participants