Skip to content

Commit 3e28975

Browse files
migration-bot-adhocmav-adhoc
authored andcommitted
[MIG] product_internal_code: Migration to 19.0
1 parent 9b4a884 commit 3e28975

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

product_internal_code/__manifest__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
{
2222
"name": "Product Internal Code",
23-
"version": "18.0.1.0.0",
23+
"version": "19.0.1.0.0",
2424
"category": "Tools",
2525
"sequence": 14,
2626
"author": "ADHOC SA",
@@ -36,7 +36,7 @@
3636
],
3737
"demo": [],
3838
"test": [],
39-
"installable": False,
39+
"installable": True,
4040
"auto_install": False,
4141
"application": False,
4242
}

product_internal_code/models/product_product.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@ class ProductProduct(models.Model):
1313
index="btree_not_null",
1414
)
1515

16+
_internal_code_uniq = models.Constraint(
17+
"unique (internal_code)",
18+
"Internal Code must be unique!",
19+
)
20+
1621
@api.model_create_multi
1722
def create(self, vals_list):
1823
for vals in vals_list:
19-
if not vals.get("internal_code", False) and not self._context.get("default_internal_code", False):
24+
if not vals.get("internal_code", False) and not self.env.context.get("default_internal_code", False):
2025
vals["internal_code"] = self.env["ir.sequence"].next_by_code("product.internal.code")
2126
return super().create(vals_list)
22-
23-
_sql_constraints = {("internal_code_uniq", "unique(internal_code)", "Internal Code must be unique!")}

0 commit comments

Comments
 (0)