Skip to content

Commit a93139f

Browse files
committed
[MIG] sale_stock_mto_as_mts_orderpoint_product_variant: Migration to 18.0
1 parent 492da0a commit a93139f

File tree

9 files changed

+54
-15
lines changed

9 files changed

+54
-15
lines changed

sale_stock_mto_as_mts_orderpoint_product_variant/README.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,15 @@ Contributors
6363
------------
6464

6565
- Matthieu Méquignon <[email protected]>
66+
- Chau Le <[email protected]>
67+
68+
Other credits
69+
-------------
70+
71+
The development and migration of this module has been financially
72+
supported by:
73+
74+
- Camptocamp
6675

6776
Maintainers
6877
-----------

sale_stock_mto_as_mts_orderpoint_product_variant/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
{
55
"name": "Sale Stock MTO as MTS Orderpoint Product Variant",
6-
"version": "14.0.1.0.0",
6+
"version": "18.0.1.0.0",
77
"development_status": "Alpha",
88
"category": "Operations/Inventory/Delivery",
99
"website": "https://github.com/OCA/stock-logistics-workflow",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
from . import product_product
2+
from . import sale_order_line

sale_stock_mto_as_mts_orderpoint_product_variant/models/product_product.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
# Copyright 2023 Camptocamp SA
22
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
33

4-
from odoo import api, models
4+
from odoo import fields, models
55

66

77
class ProductProduct(models.Model):
88
_inherit = "product.product"
99

10+
is_mto = fields.Boolean(inverse="_inverse_is_mto")
11+
1012
def _variant_is_mto(self):
1113
self.ensure_one()
1214
return self.is_mto
1315

1416
def _inverse_is_mto(self):
15-
res = super()._inverse_is_mto()
1617
self._archive_orderpoints_on_mto_removal()
17-
return res
1818

19-
@api.depends("product_tmpl_id.route_ids")
2019
def _compute_is_mto(self):
2120
# Archive orderpoints when variant becomes not mto
2221
res = super()._compute_is_mto()
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2025 Camptocamp
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
3+
from odoo import models
4+
5+
6+
class SaleOrderLine(models.Model):
7+
_inherit = "sale.order.line"
8+
9+
def _get_mto_orderpoint(self, product_id):
10+
orderpoint = super()._get_mto_orderpoint(product_id)
11+
12+
if not product_id.is_mto:
13+
orderpoint.write({"active": False})
14+
15+
return orderpoint
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
- Matthieu Méquignon \<<[email protected]>\>
2+
- Chau Le \<<[email protected]>\>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The development and migration of this module has been financially supported by:
2+
3+
- Camptocamp

sale_stock_mto_as_mts_orderpoint_product_variant/static/description/index.html

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,8 @@ <h1 class="title">Sale Stock MTO as MTS Orderpoint Product Variant</h1>
385385
<li><a class="reference internal" href="#credits" id="toc-entry-2">Credits</a><ul>
386386
<li><a class="reference internal" href="#authors" id="toc-entry-3">Authors</a></li>
387387
<li><a class="reference internal" href="#contributors" id="toc-entry-4">Contributors</a></li>
388-
<li><a class="reference internal" href="#maintainers" id="toc-entry-5">Maintainers</a></li>
388+
<li><a class="reference internal" href="#other-credits" id="toc-entry-5">Other credits</a></li>
389+
<li><a class="reference internal" href="#maintainers" id="toc-entry-6">Maintainers</a></li>
389390
</ul>
390391
</li>
391392
</ul>
@@ -410,10 +411,19 @@ <h2><a class="toc-backref" href="#toc-entry-3">Authors</a></h2>
410411
<h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
411412
<ul class="simple">
412413
<li>Matthieu Méquignon &lt;<a class="reference external" href="mailto:matthieu.mequignon&#64;camptocamp.com">matthieu.mequignon&#64;camptocamp.com</a>&gt;</li>
414+
<li>Chau Le &lt;<a class="reference external" href="mailto:chaulb&#64;trobz.com">chaulb&#64;trobz.com</a>&gt;</li>
415+
</ul>
416+
</div>
417+
<div class="section" id="other-credits">
418+
<h2><a class="toc-backref" href="#toc-entry-5">Other credits</a></h2>
419+
<p>The development and migration of this module has been financially
420+
supported by:</p>
421+
<ul class="simple">
422+
<li>Camptocamp</li>
413423
</ul>
414424
</div>
415425
<div class="section" id="maintainers">
416-
<h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
426+
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
417427
<p>This module is maintained by the OCA.</p>
418428
<a class="reference external image-reference" href="https://odoo-community.org">
419429
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />

sale_stock_mto_as_mts_orderpoint_product_variant/tests/test_mto_as_mts_variant.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def setUpClass(cls):
1515
cls.env["product.supplierinfo"].create(
1616
[
1717
{
18-
"name": cls.vendor_partner.id,
18+
"partner_id": cls.vendor_partner.id,
1919
"product_tmpl_id": variant.product_tmpl_id.id,
2020
"product_id": variant.id,
2121
"min_qty": 1.0,
@@ -25,9 +25,10 @@ def setUpClass(cls):
2525
]
2626
)
2727
cls.warehouse = cls.env.ref("stock.warehouse0")
28+
cls.warehouse.mto_as_mts = True
2829

2930
@classmethod
30-
def setUpClassProduct(cls):
31+
def setUpClassProduct(cls): # pylint: disable=missing-return
3132
super().setUpClassProduct()
3233
cls.buy_route = cls.env.ref("purchase_stock.route_warehouse0_buy")
3334
cls.template_pen.write(
@@ -46,13 +47,13 @@ def _create_sale_order(cls, products):
4647
return sale_form.save()
4748

4849
def _get_orderpoint_for_products(self, products, archived=False):
49-
orderpoint = self.env["stock.warehouse.orderpoint"]
50-
if archived:
51-
orderpoint = orderpoint.with_context(active_test=False)
52-
return orderpoint.search([("product_id", "in", products.ids)])
50+
return (
51+
self.env["stock.warehouse.orderpoint"]
52+
.with_context(active_test=not archived)
53+
.search([("product_id", "in", products.ids)])
54+
)
5355

5456
def test_mto_as_mts_orderpoint(self):
55-
template_pen = self.template_pen
5657
black_pen = self.black_pen
5758
blue_pen = self.blue_pen
5859
red_pen = self.red_pen
@@ -104,7 +105,7 @@ def test_mtp_as_mts_orderpoint_product_no_mto(self):
104105
def test_cancel_sale_order_orderpoint(self):
105106
order = self._create_sale_order(self.variants_pen)
106107
order.action_confirm()
107-
order.action_cancel()
108+
order.with_context(disable_cancel_warning=True).action_cancel()
108109
order.action_draft()
109110
order.action_confirm()
110111
self.assertEqual(order.state, "sale")

0 commit comments

Comments
 (0)