Skip to content

Commit 2a12621

Browse files
[MIG] product_variant_specific_description: Migration to 18.0
1 parent ad1561e commit 2a12621

8 files changed

Lines changed: 76 additions & 13 deletions

File tree

product_variant_specific_description/README.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ Contributors
5858
------------
5959

6060
- Lois Rilo <lois.rilo@forgeflow.com>
61+
- `Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>`__
62+
63+
- Bhavesh Heliconia
6164

6265
Maintainers
6366
-----------

product_variant_specific_description/__manifest__.py

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

44
{
55
"name": "Product Variant Specific Description",
6-
"version": "16.0.1.0.1",
6+
"version": "18.0.1.0.0",
77
"category": "Product",
88
"author": "ForgeFlow, Odoo Community Association (OCA)",
99
"website": "https://github.com/OCA/product-variant",

product_variant_specific_description/init_hook.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
logger = logging.getLogger(__name__)
77

88

9-
def post_init_hook(cr, registry):
9+
def post_init_hook(env):
1010
logger.info("Setting product variant description with product template description")
11-
cr.execute(
11+
env.cr.execute(
1212
"""
1313
UPDATE product_product pp
1414
SET description = pt.description
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
- Lois Rilo \<<lois.rilo@forgeflow.com>\>
2+
- [Heliconia Solutions Pvt. Ltd.](https://www.heliconia.io)
3+
- Bhavesh Heliconia
4+

product_variant_specific_description/static/description/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,10 @@ <h2><a class="toc-backref" href="#toc-entry-3">Authors</a></h2>
404404
<h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
405405
<ul class="simple">
406406
<li>Lois Rilo &lt;<a class="reference external" href="mailto:lois.rilo&#64;forgeflow.com">lois.rilo&#64;forgeflow.com</a>&gt;</li>
407+
<li><a class="reference external" href="https://www.heliconia.io">Heliconia Solutions Pvt. Ltd.</a><ul>
408+
<li>Bhavesh Heliconia</li>
409+
</ul>
410+
</li>
407411
</ul>
408412
</div>
409413
<div class="section" id="maintainers">
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
from . import test_product_variant_description
2+
from . import test_product_template
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
from odoo.tests import TransactionCase
2+
3+
4+
class TestProductTemplate(TransactionCase):
5+
def test_is_system_multi_lang(self):
6+
"""
7+
Test case to check if the is_system_multi_lang field is
8+
set correctly based on the system's language count.
9+
"""
10+
product_template = self.env["product.template"].create(
11+
{
12+
"name": "Test Product",
13+
}
14+
)
15+
16+
lang_count = self.env["res.lang"].search_count([])
17+
18+
# Ensure only one language exists, unlink others
19+
if lang_count > 1:
20+
langs = self.env["res.lang"].search([("code", "!=", "en_US")])
21+
langs.unlink()
22+
23+
product_template._compute_is_system_multi_lang()
24+
25+
# Check if the computed value is correct based on language count
26+
if lang_count == 1:
27+
self.assertFalse(
28+
product_template.is_system_multi_lang,
29+
"The is_system_multi_lang field should be False "
30+
"when only one language exists.",
31+
)
32+
else:
33+
self.assertTrue(
34+
product_template.is_system_multi_lang,
35+
"The is_system_multi_lang field should be True "
36+
"when multiple languages exist.",
37+
)
38+
39+
def test_prepare_variant_values(self):
40+
"""
41+
Test case to check if the description is included when preparing variant values.
42+
"""
43+
product_template = self.env["product.template"].create(
44+
{
45+
"name": "Test Product",
46+
"description": "Product template description",
47+
}
48+
)
49+
50+
# Using correct model
51+
combination = self.env["product.attribute.value"].browse([])
52+
53+
variant_values = product_template._prepare_variant_values(combination)
54+
55+
self.assertEqual(
56+
variant_values.get("description"),
57+
product_template.description,
58+
"The description should be included in the prepared variant values.",
59+
)

product_variant_specific_description/views/product_template_view.xml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,14 @@
88
<field name="inherit_id" ref="product.product_template_only_form_view" />
99
<field name="arch" type="xml">
1010
<xpath expr="//field[@name='description']/.." position="attributes">
11-
<attribute
12-
name="attrs"
13-
>{'invisible': [('product_variant_count', '>', 1)]}</attribute>
11+
<attribute name="invisible">product_variant_count > 1</attribute>
1412
</xpath>
1513
<xpath expr="//field[@name='description']" position="attributes">
16-
<attribute
17-
name="attrs"
18-
>{'readonly': [('is_system_multi_lang', '=', True)]}</attribute>
14+
<attribute name="readonly">is_system_multi_lang</attribute>
1915
</xpath>
2016
<xpath expr="//field[@name='description']" position="before">
2117
<field name="is_system_multi_lang" invisible="1" />
22-
<p
23-
colspan="2"
24-
attrs="{'invisible': [('is_system_multi_lang', '=', False)]}"
25-
>
18+
<p colspan="2" invisible="is_system_multi_lang">
2619
<i
2720
class="fa fa-info-circle"
2821
/> This field is maintained in the product variant form.

0 commit comments

Comments
 (0)