Skip to content

Commit 50fd972

Browse files
[MIG] sale_variant_configurator: Migration to version 19.0
TT61966
1 parent df817a5 commit 50fd972

7 files changed

Lines changed: 71 additions & 36 deletions

File tree

sale_variant_configurator/README.rst

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,21 @@ Sale - Product variants
2121
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
2222
:alt: License: AGPL-3
2323
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fproduct--variant-lightgray.png?logo=github
24-
:target: https://github.com/OCA/product-variant/tree/18.0/sale_variant_configurator
24+
:target: https://github.com/OCA/product-variant/tree/19.0/sale_variant_configurator
2525
:alt: OCA/product-variant
2626
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
27-
:target: https://translation.odoo-community.org/projects/product-variant-18-0/product-variant-18-0-sale_variant_configurator
27+
:target: https://translation.odoo-community.org/projects/product-variant-19-0/product-variant-19-0-sale_variant_configurator
2828
:alt: Translate me on Weblate
2929
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
30-
:target: https://runboat.odoo-community.org/builds?repo=OCA/product-variant&target_branch=18.0
30+
:target: https://runboat.odoo-community.org/builds?repo=OCA/product-variant&target_branch=19.0
3131
:alt: Try me on Runboat
3232

3333
|badge1| |badge2| |badge3| |badge4| |badge5|
3434

35-
35+
This module allows you to create the product variant when a sale order
36+
is confirmed. It adds to the sale line a product configurator, so that
37+
selecting a product and its attributes can serve for creating/selecting
38+
the product variant.
3639

3740
**Table of contents**
3841

@@ -45,7 +48,7 @@ Bug Tracker
4548
Bugs are tracked on `GitHub Issues <https://github.com/OCA/product-variant/issues>`_.
4649
In case of trouble, please check there if your issue has already been reported.
4750
If you spotted it first, help us to smash it by providing a detailed and welcomed
48-
`feedback <https://github.com/OCA/product-variant/issues/new?body=module:%20sale_variant_configurator%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
51+
`feedback <https://github.com/OCA/product-variant/issues/new?body=module:%20sale_variant_configurator%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
4952

5053
Do not contact contributors directly about support or help with technical issues.
5154

@@ -62,6 +65,14 @@ Authors
6265
Contributors
6366
------------
6467

68+
- Oihane Crucelaegui oihanecrucelaegi@avanzosc.es
69+
- `Tecnativa <https://www.tecnativa.com>`__:
70+
71+
- Pedro M. Baeza
72+
- David Vidal
73+
- Andrii Kompaniiets
74+
75+
- Ana Juaristi ajuaristio@gmail.com
6576
- [Heliconia Solutions Pvt. Ltd.](https://www.heliconia.io)
6677

6778
- Bhavesh Heliconia
@@ -79,6 +90,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
7990
mission is to support the collaborative development of Odoo features and
8091
promote its widespread use.
8192

82-
This module is part of the `OCA/product-variant <https://github.com/OCA/product-variant/tree/18.0/sale_variant_configurator>`_ project on GitHub.
93+
This module is part of the `OCA/product-variant <https://github.com/OCA/product-variant/tree/19.0/sale_variant_configurator>`_ project on GitHub.
8394

8495
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

sale_variant_configurator/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
{
88
"name": "Sale - Product variants",
99
"summary": "Product variants in sale management",
10-
"version": "18.0.1.0.3",
10+
"version": "19.0.1.0.0",
1111
"development_status": "Production/Stable",
1212
"license": "AGPL-3",
1313
"depends": ["sale", "product_variant_configurator"],

sale_variant_configurator/models/sale_order.py

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
class SaleOrder(models.Model):
1010
_inherit = "sale.order"
1111

12-
def _action_confirm(self):
12+
def action_confirm(self):
1313
"""Create possible product variants not yet created."""
1414
lines_without_product = self.mapped("order_line").filtered(
1515
lambda x: not x.product_id and x.product_tmpl_id
1616
)
1717
for line in lines_without_product:
1818
line.create_variant_if_needed()
19-
return super()._action_confirm()
19+
return super().action_confirm()
2020

2121

2222
class SaleOrderLine(models.Model):
@@ -30,25 +30,19 @@ class SaleOrderLine(models.Model):
3030
related=False,
3131
string="Product Template (no related)",
3232
)
33-
product_id = fields.Many2one(required=False)
3433

35-
_sql_constraints = [
36-
(
37-
"accountable_required_fields",
38-
"CHECK(display_type IS NOT NULL OR "
39-
"((product_id IS NOT NULL OR product_tmpl_id IS NOT NULL) AND "
40-
"product_uom IS NOT NULL))",
41-
"Missing required fields on accountable sale order line.",
42-
),
43-
(
44-
"non_accountable_null_fields",
45-
"CHECK(display_type IS NULL OR "
46-
"(product_id IS NULL AND product_tmpl_id IS NULL AND "
47-
"price_unit = 0 AND product_uom_qty = 0 AND "
48-
"product_uom IS NULL AND customer_lead = 0))",
49-
"Forbidden values on non-accountable sale order line",
50-
),
51-
]
34+
_accountable_required_fields = models.Constraint(
35+
"CHECK(display_type IS NOT NULL OR is_downpayment OR "
36+
"(product_tmpl_id IS NOT NULL OR product_id IS NOT NULL AND "
37+
"product_uom_id IS NOT NULL))",
38+
"Missing required fields on accountable sale order line.",
39+
)
40+
_non_accountable_null_fields = models.Constraint(
41+
"CHECK(display_type IS NULL OR (product_tmpl_id IS NULL AND "
42+
"product_id IS NULL AND price_unit = 0 AND product_uom_qty = 0 "
43+
"AND product_uom_id IS NULL AND customer_lead = 0))",
44+
"Forbidden values on non-accountable sale order line",
45+
)
5246

5347
@api.model_create_multi
5448
def create(self, vals_list):
@@ -105,3 +99,13 @@ def _compute_product_uom(self):
10599
line.product_uom = line.product_tmpl_id.uom_id
106100
self -= lines_with_template
107101
return super()._compute_product_uom()
102+
103+
def _get_sale_order_line_multiline_description_variants(self):
104+
# It needs to correctly show the name of the sale.order.line with attributes
105+
name = super()._get_sale_order_line_multiline_description_variants()
106+
if not self.product_attribute_ids:
107+
return name
108+
for attribute in self.product_attribute_ids:
109+
if attribute.value_id.display_name:
110+
name += "\n" + attribute.value_id.display_name
111+
return name
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1+
- Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>
2+
- [Tecnativa](https://www.tecnativa.com):
3+
- Pedro M. Baeza
4+
- David Vidal
5+
- Andrii Kompaniiets
6+
- Ana Juaristi <ajuaristio@gmail.com>
17
- \[Heliconia Solutions Pvt. Ltd.\](<https://www.heliconia.io>)
28
- Bhavesh Heliconia
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
1+
This module allows you to create the product variant when a sale order
2+
is confirmed. It adds to the sale line a product configurator,
3+
so that selecting a product and its attributes can serve for creating/selecting the product variant.

sale_variant_configurator/static/description/index.html

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,11 @@ <h1>Sale - Product variants</h1>
374374
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
375375
!! source digest: sha256:c8b6c97ac41bc39d1cea898571d5e53dca3b4ed5864f0e8a1fc681cd7cf0abec
376376
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
377-
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/product-variant/tree/18.0/sale_variant_configurator"><img alt="OCA/product-variant" src="https://img.shields.io/badge/github-OCA%2Fproduct--variant-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/product-variant-18-0/product-variant-18-0-sale_variant_configurator"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/product-variant&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
377+
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/product-variant/tree/19.0/sale_variant_configurator"><img alt="OCA/product-variant" src="https://img.shields.io/badge/github-OCA%2Fproduct--variant-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/product-variant-19-0/product-variant-19-0-sale_variant_configurator"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/product-variant&amp;target_branch=19.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
378+
<p>This module allows you to create the product variant when a sale order
379+
is confirmed. It adds to the sale line a product configurator, so that
380+
selecting a product and its attributes can serve for creating/selecting
381+
the product variant.</p>
378382
<p><strong>Table of contents</strong></p>
379383
<div class="contents local topic" id="contents">
380384
<ul class="simple">
@@ -392,7 +396,7 @@ <h2><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h2>
392396
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/product-variant/issues">GitHub Issues</a>.
393397
In case of trouble, please check there if your issue has already been reported.
394398
If you spotted it first, help us to smash it by providing a detailed and welcomed
395-
<a class="reference external" href="https://github.com/OCA/product-variant/issues/new?body=module:%20sale_variant_configurator%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
399+
<a class="reference external" href="https://github.com/OCA/product-variant/issues/new?body=module:%20sale_variant_configurator%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
396400
<p>Do not contact contributors directly about support or help with technical issues.</p>
397401
</div>
398402
<div class="section" id="credits">
@@ -408,6 +412,14 @@ <h3><a class="toc-backref" href="#toc-entry-3">Authors</a></h3>
408412
<div class="section" id="contributors">
409413
<h3><a class="toc-backref" href="#toc-entry-4">Contributors</a></h3>
410414
<ul class="simple">
415+
<li>Oihane Crucelaegui <a class="reference external" href="mailto:oihanecrucelaegi&#64;avanzosc.es">oihanecrucelaegi&#64;avanzosc.es</a></li>
416+
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
417+
<li>Pedro M. Baeza</li>
418+
<li>David Vidal</li>
419+
<li>Andrii Kompaniiets</li>
420+
</ul>
421+
</li>
422+
<li>Ana Juaristi <a class="reference external" href="mailto:ajuaristio&#64;gmail.com">ajuaristio&#64;gmail.com</a></li>
411423
<li>[Heliconia Solutions Pvt. Ltd.](<a class="reference external" href="https://www.heliconia.io">https://www.heliconia.io</a>)<ul>
412424
<li>Bhavesh Heliconia</li>
413425
</ul>
@@ -423,7 +435,7 @@ <h3><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h3>
423435
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
424436
mission is to support the collaborative development of Odoo features and
425437
promote its widespread use.</p>
426-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/product-variant/tree/18.0/sale_variant_configurator">OCA/product-variant</a> project on GitHub.</p>
438+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/product-variant/tree/19.0/sale_variant_configurator">OCA/product-variant</a> project on GitHub.</p>
427439
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
428440
</div>
429441
</div>

sale_variant_configurator/tests/test_sale_order.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def test_onchange_product_tmpl_id(self):
7777
"name": "Line 1",
7878
"product_tmpl_id": self.product_template_yes.id,
7979
"price_unit": 100,
80-
"product_uom": self.product_template_yes.uom_id.id,
80+
"product_uom_id": self.product_template_yes.uom_id.id,
8181
"product_uom_qty": 1,
8282
}
8383
)
@@ -135,7 +135,7 @@ def _test_can_create_product_variant(self):
135135
"product_tmpl_id": self.product_template_yes.id,
136136
"price_unit": 100,
137137
"name": "Line 1",
138-
"product_uom": self.product_template_yes.uom_id.id,
138+
"product_uom_id": self.product_template_yes.uom_id.id,
139139
}
140140
)
141141
self.assertFalse(line.can_create_product)
@@ -182,7 +182,7 @@ def test_onchange_product_id(self):
182182
"price_unit": 100,
183183
"name": "Line 1",
184184
"product_uom_qty": 1,
185-
"product_uom": product.uom_id.id,
185+
"product_uom_id": product.uom_id.id,
186186
},
187187
)
188188
],
@@ -203,7 +203,7 @@ def _test_action_confirm(self):
203203
"price_unit": 100,
204204
"name": "Line 1",
205205
"product_uom_qty": 1,
206-
"product_uom": self.product_template_yes.uom_id.id,
206+
"product_uom_id": self.product_template_yes.uom_id.id,
207207
"product_attribute_ids": [
208208
Command.create(
209209
{
@@ -221,7 +221,7 @@ def _test_action_confirm(self):
221221
{
222222
"order_id": order.id,
223223
"product_tmpl_id": self.product_template_no.id,
224-
"product_uom": self.product_template_no.uom_id.id,
224+
"product_uom_id": self.product_template_no.uom_id.id,
225225
"product_uom_qty": 1,
226226
"price_unit": 200,
227227
"name": "Line 2",

0 commit comments

Comments
 (0)