Skip to content

[18.0][ADD] stock_orderpoint_variant_mto_as_mts - #58

Open
henrybackman wants to merge 2 commits into
OCA:18.0from
camptocamp:18.0-add-stock_orderpoint_variant_mto_as_mts
Open

[18.0][ADD] stock_orderpoint_variant_mto_as_mts#58
henrybackman wants to merge 2 commits into
OCA:18.0from
camptocamp:18.0-add-stock_orderpoint_variant_mto_as_mts

Conversation

@henrybackman

@henrybackman henrybackman commented Nov 10, 2025

Copy link
Copy Markdown
Contributor

Glue module between stock_orderpoint_mto_as_mts and product_variant_route_mto to trigger reordering rules for product variants

Depends on:

@henrybackman
henrybackman force-pushed the 18.0-add-stock_orderpoint_variant_mto_as_mts branch 2 times, most recently from 861dc38 to 662a918 Compare November 10, 2025 18:42
@henrybackman

Copy link
Copy Markdown
Contributor Author

@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.

Comment thread stock_orderpoint_variant_mto_as_mts/readme/CONFIGURE.md Outdated
@jbaudoux
jbaudoux force-pushed the 18.0-add-stock_orderpoint_variant_mto_as_mts branch 3 times, most recently from 6d8d3a4 to be018ab Compare November 12, 2025 13:43
Co-author: Jacques-Etienne Baudoux (BCIM) <je@bcim.be>
@jbaudoux
jbaudoux force-pushed the 18.0-add-stock_orderpoint_variant_mto_as_mts branch from be018ab to ea5fb1a Compare November 12, 2025 13:44
@jbaudoux

Copy link
Copy Markdown
Contributor

@henrybackman

Copy link
Copy Markdown
Contributor Author

"name": "Test MTO",
"type": "consu",
"is_storable": True,
"route_ids": [(6, 0, [self.mto_route.id])],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
"route_ids": [(6, 0, [self.mto_route.id])],
"route_ids": [Command.link(self.mto_route.id)],

@sebalix

sebalix commented Nov 14, 2025

Copy link
Copy Markdown

PR to rebase (dependency merged)

@jbaudoux

Copy link
Copy Markdown
Contributor

PR to rebase (dependency merged)

It's missing post install tag

@TDu
TDu force-pushed the 18.0-add-stock_orderpoint_variant_mto_as_mts branch from ea5fb1a to 38014a2 Compare November 26, 2025 09:09
@TDu

TDu commented Nov 26, 2025

Copy link
Copy Markdown
Member

Rebased

@TDu
TDu force-pushed the 18.0-add-stock_orderpoint_variant_mto_as_mts branch from bc6bdf7 to e1f3bdb Compare November 26, 2025 10:07
@TDu
TDu force-pushed the 18.0-add-stock_orderpoint_variant_mto_as_mts branch from e1f3bdb to 8027a4f Compare November 26, 2025 10:09

@mmequignon mmequignon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If I'm right in my assumption, we are missing something

Comment on lines +21 to +24
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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

Comment on lines +21 to +22
mto_routes = self.env["stock.route"].search([("is_mto", "=", True)])
if not mto_routes:

@mmequignon mmequignon Dec 18, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good point

Comment on lines +18 to +25
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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
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

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