Skip to content

Commit 0c098d0

Browse files
committed
[MIG] barcodes_generator_product: Migration to 17.0
- Migrate views using the module `views_migration_v17` - Remove the 'priority' field in views. - Remove the 'replace' attribute from views and apply the 'after' attribute instead. - Migrate setUp to setUpClass. - Apply command syntax. - Fix the unordered list in DESCRIPTION.md and README.rst files.
1 parent 5b48ff7 commit 0c098d0

File tree

8 files changed

+63
-71
lines changed

8 files changed

+63
-71
lines changed

barcodes_generator_product/README.rst

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,19 @@ This module expands Odoo functionality, allowing user to generate
3232
barcode depending on a given barcode rule for Products.
3333

3434
For example, a typical pattern for products is "20.....{NNNDD}" that
35-
means that: \* the EAN13 code will begin by '20' \* followed by 5 digits
36-
(named Barcode Base in this module) \* and after 5 others digits to
37-
define the variable price \* a 13 digit control
35+
means that:
36+
* the EAN13 code will begin by '20'
37+
* followed by 5 digits (named Barcode Base in this module)
38+
* and after 5 others digits to define the variable price
39+
* a 13 digit control
3840

39-
Another common pattern is "8012345....." which means that: \* the EAN13
40-
code will begin with '8012345' \* followed by 5 digits (named Barcode
41-
Base in this module) \* and finally the 13th digit is the control digit
41+
Another common pattern is "8012345....." which means that:
42+
* the EAN13 code will begin with '8012345'
43+
* followed by 5 digits (named Barcode Base in this module)
44+
* and finally the 13th digit is the control digit.
4245

4346
Note that a dot is not necessary in the pattern as the control digit is
44-
added automatically.
47+
added automatically
4548

4649
With this module, it is possible to:
4750

barcodes_generator_product/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
{
88
"name": "Generate Barcodes for Products",
99
"summary": "Generate Barcodes for Products (Templates and Variants)",
10-
"version": "16.0.2.1.0",
10+
"version": "17.0.1.0.0",
1111
"category": "Tools",
1212
"author": "GRAP, La Louve, Odoo Community Association (OCA)",
1313
"website": "https://github.com/OCA/stock-logistics-barcode",

barcodes_generator_product/demo/product.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
2525
<field name="attribute_id" ref="product.product_attribute_2" />
2626
<field
2727
name="value_ids"
28-
eval="[(6, 0, [ref('product.product_attribute_value_3'), ref('product.product_attribute_value_4')])]"
28+
eval="[Command.set([ref('product.product_attribute_value_3'), ref('product.product_attribute_value_4')])]"
2929
/>
3030
</record>
3131

@@ -78,14 +78,14 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
7878
<field name="attribute_id" ref="product.product_attribute_2" />
7979
<field
8080
name="value_ids"
81-
eval="[(6,0,[ref('product.product_attribute_value_3'), ref('product.product_attribute_value_4')])]"
81+
eval="[Command.set([ref('product.product_attribute_value_3'), ref('product.product_attribute_value_4')])]"
8282
/>
8383
</record>
8484

8585
<record id="product_template_multi_variant" model="product.template">
8686
<field
8787
name="attribute_line_ids"
88-
eval="[(6,0,[ref('product_template_multi_variant_attribute_line')])]"
88+
eval="[Command.set([ref('product_template_multi_variant_attribute_line')])]"
8989
/>
9090
</record>
9191
</odoo>

barcodes_generator_product/demo/res_users.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
1010
<field
1111
name="groups_id"
1212
eval="[
13-
(4, ref('product.group_product_variant')),
13+
Command.link(ref('product.group_product_variant')),
1414
]"
1515
/>
1616
</record>

barcodes_generator_product/readme/DESCRIPTION.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@ This module expands Odoo functionality, allowing user to generate
22
barcode depending on a given barcode rule for Products.
33

44
For example, a typical pattern for products is "20.....{NNNDD}" that
5-
means that: \* the EAN13 code will begin by '20' \* followed by 5 digits
6-
(named Barcode Base in this module) \* and after 5 others digits to
7-
define the variable price \* a 13 digit control
5+
means that:
6+
* the EAN13 code will begin by '20'
7+
* followed by 5 digits (named Barcode Base in this module)
8+
* and after 5 others digits to define the variable price
9+
* a 13 digit control
810

9-
Another common pattern is "8012345....." which means that: \* the EAN13
10-
code will begin with '8012345' \* followed by 5 digits (named Barcode
11-
Base in this module) \* and finally the 13th digit is the control digit
11+
Another common pattern is "8012345....." which means that:
12+
* the EAN13 code will begin with '8012345'
13+
* followed by 5 digits (named Barcode Base in this module)
14+
* and finally the 13th digit is the control digit
1215

1316
Note that a dot is not necessary in the pattern as the control digit is
1417
added automatically.

barcodes_generator_product/tests/test_barcodes_generator_product.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
class Tests(TransactionCase):
1010
"""Tests 'Barcodes Generator for Products'"""
1111

12-
def setUp(self):
13-
super().setUp()
14-
self.ProductTemplate = self.env["product.template"]
15-
self.ProductProduct = self.env["product.product"]
16-
self.barcode_rule_manually = self.env.ref(
12+
@classmethod
13+
def setUpClass(cls):
14+
super().setUpClass()
15+
cls.ProductTemplate = cls.env["product.template"]
16+
cls.ProductProduct = cls.env["product.product"]
17+
cls.barcode_rule_manually = cls.env.ref(
1718
"barcodes_generator_product.rule_product_generated_barcode_manually"
1819
)
1920

barcodes_generator_product/views/view_product_product.xml

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
1010
<record id="view_product_product_form" model="ir.ui.view">
1111
<field name="model">product.product</field>
1212
<field name="inherit_id" ref="product.product_normal_form_view" />
13-
<field name="priority">100</field>
1413
<field name="arch" type="xml">
1514
<field name="barcode" position="before">
1615
<field
@@ -24,18 +23,18 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
2423
<field name="generate_type" invisible="1" />
2524
<label
2625
for="barcode_base"
27-
attrs="{'invisible': [('barcode_rule_id', '=', False)]}"
26+
invisible="not barcode_rule_id"
2827
groups="barcodes_generator_abstract.generate_barcode"
2928
/>
3029
<div
3130
name="div_barcode_base"
3231
class="o_row"
33-
attrs="{'invisible': [('barcode_rule_id', '=', False)]}"
32+
invisible="not barcode_rule_id"
3433
groups="barcodes_generator_abstract.generate_barcode"
3534
>
3635
<field
3736
name="barcode_base"
38-
attrs="{'readonly': [('generate_type', '!=', 'manual')]}"
37+
readonly="generate_type != 'manual'"
3938
groups="barcodes_generator_abstract.generate_barcode"
4039
class="oe_inline"
4140
/>
@@ -44,33 +43,30 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
4443
type="object"
4544
string="Generate Base"
4645
help="Generate Base (Using Sequence)"
47-
attrs="{'invisible': ['|',
48-
('generate_type', '!=', 'sequence'),
49-
('barcode_base', '!=', 0),
50-
]}"
46+
invisible="generate_type != 'sequence' or barcode_base != 0"
5147
groups="barcodes_generator_abstract.generate_barcode"
5248
class="oe_inline"
5349
/>
5450
</div>
5551
</field>
5652

57-
<field name="barcode" position="replace">
53+
<field name="barcode" position="attributes">
54+
<attribute name="invisible">True</attribute>
55+
</field>
56+
<field name="barcode" position="after">
5857
<label for="barcode" />
5958
<div name="div_barcode" class="o_row">
6059
<field
6160
name="barcode"
6261
class="oe_inline"
63-
attrs="{'readonly': [('generate_type', '=', 'sequence')]}"
62+
readonly="generate_type == 'sequence'"
6463
/>
6564
<button
6665
name="generate_barcode"
6766
type="object"
6867
string="Generate Barcode"
6968
help="Generate Barcode (Using Barcode Rule)"
70-
attrs="{'invisible': ['|',
71-
('barcode_rule_id', '=', False),
72-
('barcode_base', '=', 0),
73-
]}"
69+
invisible="not barcode_rule_id or barcode_base == 0"
7470
groups="barcodes_generator_abstract.generate_barcode"
7571
class="oe_inline"
7672
/>
@@ -83,7 +79,6 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
8379
<record id="product_variant_easy_edit_view" model="ir.ui.view">
8480
<field name="model">product.product</field>
8581
<field name="inherit_id" ref="product.product_variant_easy_edit_view" />
86-
<field name="priority">100</field>
8782
<field name="arch" type="xml">
8883
<field name="barcode" position="before">
8984
<field
@@ -97,18 +92,18 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
9792
<field name="generate_type" invisible="1" />
9893
<label
9994
for="barcode_base"
100-
attrs="{'invisible': [('barcode_rule_id', '=', False)]}"
95+
invisible="not barcode_rule_id"
10196
groups="barcodes_generator_abstract.generate_barcode"
10297
/>
10398
<div
10499
name="div_barcode_base"
105100
class="o_row"
106-
attrs="{'invisible': [('barcode_rule_id', '=', False)]}"
101+
invisible="not barcode_rule_id"
107102
groups="barcodes_generator_abstract.generate_barcode"
108103
>
109104
<field
110105
name="barcode_base"
111-
attrs="{'readonly': [('generate_type', '!=', 'manual')]}"
106+
readonly="generate_type != 'manual'"
112107
groups="barcodes_generator_abstract.generate_barcode"
113108
class="oe_inline"
114109
/>
@@ -117,17 +112,17 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
117112
type="object"
118113
string="Generate Base"
119114
help="Generate Base (Using Sequence)"
120-
attrs="{'invisible': ['|',
121-
('generate_type', '!=', 'sequence'),
122-
('barcode_base', '!=', 0),
123-
]}"
115+
invisible="generate_type != 'sequence' or barcode_base != 0"
124116
groups="barcodes_generator_abstract.generate_barcode"
125117
class="oe_inline"
126118
/>
127119
</div>
128120
</field>
129121

130-
<field name="barcode" position="replace">
122+
<field name="barcode" position="attributes">
123+
<attribute name="invisible">True</attribute>
124+
</field>
125+
<field name="barcode" position="after">
131126
<label
132127
for="barcode"
133128
groups="barcodes_generator_abstract.generate_barcode"
@@ -136,17 +131,14 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
136131
<field
137132
name="barcode"
138133
class="oe_inline"
139-
attrs="{'readonly': [('generate_type', '=', 'sequence')]}"
134+
readonly="generate_type == 'sequence'"
140135
/>
141136
<button
142137
name="generate_barcode"
143138
type="object"
144139
string="Generate Barcode"
145140
help="Generate Barcode (Using Barcode Rule)"
146-
attrs="{'invisible': ['|',
147-
('barcode_rule_id', '=', False),
148-
('barcode_base', '=', 0),
149-
]}"
141+
invisible="not barcode_rule_id or barcode_base == 0"
150142
groups="barcodes_generator_abstract.generate_barcode"
151143
class="oe_inline"
152144
/>

barcodes_generator_product/views/view_product_template.xml

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,32 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
99
<record id="view_product_template_form" model="ir.ui.view">
1010
<field name="model">product.template</field>
1111
<field name="inherit_id" ref="product.product_template_only_form_view" />
12-
<field name="priority">100</field>
1312
<field name="arch" type="xml">
1413
<field name="barcode" position="before">
1514
<field
1615
name="barcode_rule_id"
1716
options="{'no_create': True}"
1817
domain="[('generate_model', '=', 'product.product')]"
1918
groups="barcodes_generator_abstract.generate_barcode"
20-
attrs="{'invisible': [('product_variant_count', '&gt;', 1)]}"
19+
invisible="product_variant_count &gt; 1"
2120
colspan="2"
2221
widget="selection"
2322
/>
2423
<field name="generate_type" invisible="1" />
2524
<label
2625
for="barcode_base"
27-
attrs="{'invisible': ['|', ('barcode_rule_id', '=', False), ('product_variant_count', '&gt;', 1)]}"
26+
invisible="not barcode_rule_id or product_variant_count &gt; 1"
2827
groups="barcodes_generator_abstract.generate_barcode"
2928
/>
3029
<div
3130
name="div_barcode_base"
3231
class="o_row"
33-
attrs="{'invisible': ['|', ('barcode_rule_id', '=', False), ('product_variant_count', '&gt;', 1)]}"
32+
invisible="not barcode_rule_id or product_variant_count &gt; 1"
3433
groups="barcodes_generator_abstract.generate_barcode"
3534
>
3635
<field
3736
name="barcode_base"
38-
attrs="{'readonly': [('generate_type', '!=', 'manual')]}"
37+
readonly="generate_type != 'manual'"
3938
groups="barcodes_generator_abstract.generate_barcode"
4039
class="oe_inline"
4140
/>
@@ -44,40 +43,34 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
4443
type="object"
4544
string="Generate Base"
4645
help="Generate Base (Using Sequence)"
47-
attrs="{'invisible': ['|',
48-
('generate_type', '!=', 'sequence'),
49-
('barcode_base', '!=', 0),
50-
]}"
46+
invisible="generate_type != 'sequence' or barcode_base != 0"
5147
groups="barcodes_generator_abstract.generate_barcode"
5248
class="oe_inline"
5349
/>
5450
</div>
5551
</field>
5652

57-
<field name="barcode" position="replace">
58-
<label
59-
for="barcode"
60-
attrs="{'invisible': [('product_variant_count', '&gt;', 1)]}"
61-
/>
53+
<field name="barcode" position="attributes">
54+
<attribute name="invisible">True</attribute>
55+
</field>
56+
<field name="barcode" position="after">
57+
<label for="barcode" invisible="product_variant_count &gt; 1" />
6258
<div
6359
name="div_barcode"
6460
class="o_row"
65-
attrs="{'invisible': [('product_variant_count', '&gt;', 1)]}"
61+
invisible="product_variant_count &gt; 1"
6662
>
6763
<field
6864
name="barcode"
6965
class="oe_inline"
70-
attrs="{'readonly': [('generate_type', '=', 'sequence')]}"
66+
readonly="generate_type == 'sequence'"
7167
/>
7268
<button
7369
name="generate_barcode"
7470
type="object"
7571
string="Generate Barcode"
7672
help="Generate Barcode (Using Barcode Rule)"
77-
attrs="{'invisible': ['|',
78-
('barcode_rule_id', '=', False),
79-
('barcode_base', '=', 0),
80-
]}"
73+
invisible="not barcode_rule_id or barcode_base == 0"
8174
groups="barcodes_generator_abstract.generate_barcode"
8275
class="oe_inline"
8376
/>

0 commit comments

Comments
 (0)