[18.0][MIG] product_variant_route_mto: Migration to 18.0#1879
[18.0][MIG] product_variant_route_mto: Migration to 18.0#1879
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.
| "stock.route", | ||
| compute="_compute_route_ids", | ||
| domain="[('product_selectable', '=', True)]", | ||
| store=True, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Please point the open PR in v14 fixing this so that it can be ported once finished
There was a problem hiding this comment.
I agree.
@chaule97 can you please drop the store attribute and add a search function (if necessary)?
Just here, not on v14 for now.
There was a problem hiding this comment.
I have updated it, please review my new updates
6871f14 to
6ec3dde
Compare
grindtildeath
left a comment
There was a problem hiding this comment.
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)] |
There was a problem hiding this comment.
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.
OCA/stock-logistics-workflowtoOCA/product-attribute, rename itproduct_variant_route_mtoroute_idsstored=Truebecause this code made errorNon-stored field product.product.route_ids cannot be searched.