Skip to content

Commit 496cfcc

Browse files
committed
[MIG] product_unique_internal_reference: Migration to 18.0
1 parent 56b3b18 commit 496cfcc

File tree

8 files changed

+36
-16
lines changed

8 files changed

+36
-16
lines changed

product_unique_internal_reference/README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Contributors
5656

5757
- Eric Antones eantones@nuobit.com
5858
- Bijaya Kumal bkumal@nuobit.com
59+
- Deniz Gallo dgallo@nuobit.com
5960

6061
Maintainers
6162
-----------

product_unique_internal_reference/__manifest__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# Copyright NuoBiT - Eric Antones <eantones@nuobit.com>
22
# Copyright NuoBiT 2025 - Bijaya Kumal <bkumal@nuobit.com>
3+
# Copyright NuoBiT 2025 - Deniz Galllo <dgallo@nuobit.com>
34
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
45

56
{
67
"name": "Product unique internal reference",
78
"summary": "This module ensures that you enter a "
89
"Unique Internal Reference (default_code) for your Products",
9-
"version": "16.0.1.0.0",
10+
"version": "18.0.1.0.0",
1011
"category": "Sales",
1112
"author": "NuoBiT Solutions SL",
1213
"website": "https://github.com/NuoBiT/odoo-addons",
Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
# Copyright NuoBiT - Eric Antones <eantones@nuobit.com>
2+
# Copyright NuoBiT 2025 - Deniz Galllo <dgallo@nuobit.com>
23
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
34

45

56
from odoo import _
67
from odoo.exceptions import ValidationError
78

89

9-
def internal_reference_duplicate_check(cr):
10+
def internal_reference_duplicate_check(env):
1011
"""This hook will look to see if any conflicting internal references exist before
1112
the module is installed
12-
:param odoo.sql_db.Cursor cr:
13-
Database cursor.
13+
:param Odoo env: Odoo environment
1414
"""
15-
with cr.savepoint():
16-
cr.execute(
15+
with env.cr.savepoint():
16+
env.cr.execute(
1717
"""
1818
SELECT p0.id, p0.default_code, t0.company_id
1919
FROM product_product p0, product_template t0
@@ -27,8 +27,10 @@ def internal_reference_duplicate_check(cr):
2727
p1.default_code = p0.default_code AND p1.id != p0.id
2828
)"""
2929
)
30-
products = sorted(["[%i] %s (%i)" % p for p in cr.fetchall()])
30+
products = sorted(["[%i] %s (%i)" % p for p in env.cr.fetchall()])
3131
if products:
3232
raise ValidationError(
33-
_("Conflicting internal references exist: %s" % ", ".join(products))
33+
_("Conflicting internal references exist: {}").format(
34+
", ".join(products)
35+
)
3436
)

product_unique_internal_reference/i18n/es.po

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ msgid ""
4949
"It has been possible to change the template Internal Reference existing a "
5050
"variant with the same one"
5151
msgstr ""
52+
"Ha sido posible cambiar la referencia interna de la plantilla existiendo una "
53+
"variante con la misma"
5254

5355
#. module: product_unique_internal_reference
5456
#: code:addons/product_unique_internal_reference/tests/test_product_unique_internal_reference.py:0
@@ -57,6 +59,8 @@ msgid ""
5759
"It has been possible to create a product template on one company and another"
5860
" without company with the same Internal Reference"
5961
msgstr ""
62+
"Ha sido posible crear una plantilla de producto en una compañía y otra sin "
63+
"compañía con la misma referencia interna"
6064

6165
#. module: product_unique_internal_reference
6266
#: code:addons/product_unique_internal_reference/tests/test_product_unique_internal_reference.py:0
@@ -65,6 +69,8 @@ msgid ""
6569
"It has been possible to create a product template when a variant of another "
6670
"template has the same Internal Reference"
6771
msgstr ""
72+
"Ha sido posible crear una plantilla de producto cuando una variante de otra "
73+
"plantilla tiene la misma referencia interna"
6874

6975
#. module: product_unique_internal_reference
7076
#: code:addons/product_unique_internal_reference/tests/test_product_unique_internal_reference.py:0
@@ -74,6 +80,8 @@ msgid ""
7480
"It has been possible to create a product variant when a variant of another "
7581
"template has the same Internal Reference"
7682
msgstr ""
83+
"Ha sido posible crear una variante de producto cuando una variante de otra "
84+
"plantilla tiene la misma referencia interna"
7785

7886
#. module: product_unique_internal_reference
7987
#: code:addons/product_unique_internal_reference/tests/test_product_unique_internal_reference.py:0
@@ -82,6 +90,8 @@ msgid ""
8290
"It has been possible to create two product templates with the same Internal "
8391
"Reference"
8492
msgstr ""
93+
"Ha sido posible crear dos plantillas de producto con la misma referencia "
94+
"interna"
8595

8696
#. module: product_unique_internal_reference
8797
#: model:ir.model.fields,field_description:product_unique_internal_reference.field_product_product____last_update
@@ -108,3 +118,5 @@ msgid ""
108118
"The Internal References are not equal, this should have not raised an "
109119
"Exception"
110120
msgstr ""
121+
"Las referencias internas no son iguales, esto no debería haber lanzado una "
122+
"excepción"

product_unique_internal_reference/models/product_product.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Copyright NuoBiT - Eric Antones <eantones@nuobit.com>
2+
# Copyright NuoBiT 2025 - Deniz Galllo <dgallo@nuobit.com>
23
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
34

45

@@ -39,7 +40,7 @@ def _check_default_code(self):
3940
if product:
4041
raise ValidationError(
4142
_(
42-
"Error! The Default Code %s already exists. "
43-
"Check also the archived ones." % record.default_code
44-
)
43+
"Error! The Default Code {} already exists. "
44+
"Check also the archived ones."
45+
).format(record.default_code)
4546
)

product_unique_internal_reference/models/product_template.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Copyright NuoBiT - Eric Antones <eantones@nuobit.com>
2+
# Copyright NuoBiT 2025 - Deniz Galllo <dgallo@nuobit.com>
23
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
34

45

@@ -26,20 +27,20 @@ def _check_default_code(self):
2627
)
2728
# products inside the same template
2829
products_inside = products_all.filtered(
29-
lambda p: p.product_tmpl_id == record
30+
lambda p, record=record: p.product_tmpl_id == record
3031
)
3132
# products outside the same template
3233
products_outside = products_all - products_inside
3334
if record.company_id:
3435
products_outside = products_outside.filtered(
35-
lambda p: not p.product_tmpl_id.company_id
36+
lambda p, record=record: not p.product_tmpl_id.company_id
3637
or p.product_tmpl_id.company_id == record.company_id
3738
)
3839
# check if the default code is used in other templates
3940
if len(products_inside) > 1 or products_outside:
4041
raise ValidationError(
4142
_(
42-
"Error! The Default Code %s already exists. "
43-
"Check also the archived ones." % record.default_code
44-
)
43+
"Error! The Default Code {} already exists. "
44+
"Check also the archived ones."
45+
).format(record.default_code)
4546
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
- [NuoBiT](https://www.nuobit.com):
22
- Eric Antones <eantones@nuobit.com>
33
- Bijaya Kumal <bkumal@nuobit.com>
4+
- Deniz Gallo <dgallo@nuobit.com>

product_unique_internal_reference/static/description/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ <h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
409409
<li><a class="reference external" href="https://www.nuobit.com">NuoBiT</a>:<ul>
410410
<li>Eric Antones <a class="reference external" href="mailto:eantones&#64;nuobit.com">eantones&#64;nuobit.com</a></li>
411411
<li>Bijaya Kumal <a class="reference external" href="mailto:bkumal&#64;nuobit.com">bkumal&#64;nuobit.com</a></li>
412+
<li>Deniz Gallo <a class="reference external" href="mailto:dgallo&#64;nuobit.com">dgallo&#64;nuobit.com</a></li>
412413
</ul>
413414
</li>
414415
</ul>

0 commit comments

Comments
 (0)