Skip to content

Commit c5fb225

Browse files
committed
[MIG] product_code_mandatory: Migration to 17.0
1 parent 13de979 commit c5fb225

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

product_code_mandatory/__init__.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
from . import models
22

3-
from odoo import api, SUPERUSER_ID
43

5-
6-
def pre_init_product_code(cr):
7-
env = api.Environment(cr, SUPERUSER_ID, {})
8-
9-
cr.execute(
4+
def pre_init_product_code(env):
5+
env.cr.execute(
106
"""
117
SELECT product_tmpl_id from product_product
128
WHERE default_code is NULL
139
OR LENGTH(default_code) = 0
1410
GROUP BY product_tmpl_id
1511
HAVING COUNT(product_tmpl_id) = 1"""
1612
)
17-
product_template_ids = [x[0] for x in cr.fetchall()]
18-
cr.execute(
13+
product_template_ids = [x[0] for x in env.cr.fetchall()]
14+
env.cr.execute(
1915
"""UPDATE product_product
2016
SET default_code = 'DEFAULT' || nextval('ir_default_id_seq')
2117
WHERE default_code is NULL

product_code_mandatory/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"name": "Product Code Mandatory",
66
"summary": "Set Product Internal Reference as a required field",
7-
"version": "16.0.1.0.0",
7+
"version": "17.0.1.0.0",
88
"license": "AGPL-3",
99
"author": "Open Source Integrators, Odoo Community Association (OCA)",
1010
"category": "Product",

product_code_mandatory/views/product_view.xml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66
<field name="inherit_id" ref="product.product_template_only_form_view" />
77
<field name="arch" type="xml">
88
<field name="default_code" position="attributes">
9-
<attribute
10-
name="attrs"
11-
>{'invisible': [('product_variant_count', '&gt;', 1)],
12-
'required': [('product_variant_count', '=', 1)]}</attribute>
9+
<attribute name="invisible">product_variant_count &gt;=1</attribute>
10+
<attribute name="required">product_variant_count == 1</attribute>
1311
</field>
1412
</field>
1513
</record>

0 commit comments

Comments
 (0)