[18.0][ADD] stock_orderpoint_variant_mto_as_mts - #58
Conversation
861dc38 to
662a918
Compare
|
@jbaudoux Could you check if I've implemented this glue module according to the specifications or why the tests are failing? Adding this module breaks multiple other tests for other modules but I wasn't able to pinpoint a clear reason for this to propose a fix. |
6d8d3a4 to
be018ab
Compare
Co-author: Jacques-Etienne Baudoux (BCIM) <je@bcim.be>
be018ab to
ea5fb1a
Compare
|
@henrybackman There should be one last test failing. I added this https://github.com/camptocamp/stock-logistics-orderpoint/blob/ea5fb1aadd5144aeac8425074563c691988a9866/stock_orderpoint_variant_mto_as_mts/models/stock_route.py |
@jbaudoux There's 4 tests still failing |
| "name": "Test MTO", | ||
| "type": "consu", | ||
| "is_storable": True, | ||
| "route_ids": [(6, 0, [self.mto_route.id])], |
There was a problem hiding this comment.
| "route_ids": [(6, 0, [self.mto_route.id])], | |
| "route_ids": [Command.link(self.mto_route.id)], |
|
PR to rebase (dependency merged) |
It's missing post install tag |
ea5fb1a to
38014a2
Compare
|
Rebased |
bc6bdf7 to
e1f3bdb
Compare
e1f3bdb to
8027a4f
Compare
mmequignon
left a comment
There was a problem hiding this comment.
If I'm right in my assumption, we are missing something
| mto_routes = self.env["stock.route"].search([("is_mto", "=", True)]) | ||
| if not mto_routes: | ||
| # When the last mto route is unflagged | ||
| products.is_mto = False |
There was a problem hiding this comment.
I'm not sure I understand this right.
We are looking for routes that aren't MTO, but we arent filtering based on product.route_ids.
He're my thinking:
mto_routes = self.env["stock.route"].search([("is_mto", "=", True)])
1, 2 # routes with id 1 and 2 are MTO
products.route_ids.is_mto
False # However none of the routes on products are MTO
In this case we wouldn't set is_mto False on products, and I believe we should.
Am I missing something here ?
@henrybackman @jbaudoux
| mto_routes = self.env["stock.route"].search([("is_mto", "=", True)]) | ||
| if not mto_routes: |
There was a problem hiding this comment.
here, self.is_mto is True since vals["is_mto"] is False.
mto_routes should always contain self.
This condition will never be met.
super() has to be called before, or self excluded from the search
| if vals["is_mto"]: | ||
| products.is_mto = True | ||
| else: | ||
| mto_routes = self.env["stock.route"].search([("is_mto", "=", True)]) | ||
| if not mto_routes: | ||
| # When the last mto route is unflagged | ||
| products.is_mto = False | ||
| return super().write(vals) |
There was a problem hiding this comment.
| if vals["is_mto"]: | |
| products.is_mto = True | |
| else: | |
| mto_routes = self.env["stock.route"].search([("is_mto", "=", True)]) | |
| if not mto_routes: | |
| # When the last mto route is unflagged | |
| products.is_mto = False | |
| return super().write(vals) | |
| res = super().write(vals) | |
| if vals["is_mto"]: | |
| mto_products = products.filtered(lambda p: any(p.route_ids.mapped("is_mto"))) | |
| mto_products.is_mto = True | |
| else: | |
| not_mto_products = products.filtered(lambda p: not any(p.route_ids.mapped("is_mto"))) | |
| not_mto_products.is_mto = False | |
| return res |
I was thinking about smth like that
Glue module between
stock_orderpoint_mto_as_mtsandproduct_variant_route_mtoto trigger reordering rules for product variantsDepends on: