Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
414c977
[ADD] Module to add a constraint on the internal reference of the pro…
agyamuta Feb 28, 2018
228ec64
[UPD] Update product_code_unique.pot
oca-travis Jun 21, 2018
2784850
[MIG]product_code_unique: migration from 11 to 12
bizzappdev Nov 25, 2018
3eb3c5b
[MIG] product_code_unique: Migration to 13.0
rven Oct 1, 2019
2141373
[UPD] Update product_code_unique.pot
oca-travis Oct 7, 2019
f73a5e7
[UPD] README.rst
OCA-git-bot Oct 7, 2019
e02fc88
pre-commit, black, isort
OCA-git-bot Oct 12, 2019
7aef217
[MIG] product_supplierinfo_for_customer: Migration to v13.0
sergio-teruel Feb 4, 2020
3d30421
[13.0][FIXUP] .isort.cfg
HviorForgeFlow Feb 26, 2020
588392a
[MIG] product_code_unique: Migration to 14.0
watthanun Nov 10, 2020
c86a4a9
[UPD] Update product_code_unique.pot
oca-travis Nov 17, 2020
3b3cd79
[UPD] README.rst
OCA-git-bot Nov 17, 2020
950794b
Added translation using Weblate (French)
Yvesldff Apr 10, 2021
da662ce
Translated using Weblate (French)
Yvesldff Apr 10, 2021
e042464
Added translation using Weblate (French (France))
Yvesldff Apr 10, 2021
69dd8f0
Translated using Weblate (French (France))
Yvesldff Apr 10, 2021
f31e2d0
[MIG] product_code_unique: Migration to 15.0
Jan 24, 2022
4ce3de9
Added translation using Weblate (Catalan)
pablontura Apr 22, 2022
c232752
Translated using Weblate (Catalan)
pablontura Apr 22, 2022
af17c87
Added translation using Weblate (German)
Apr 28, 2022
292b872
Translated using Weblate (German)
Apr 28, 2022
9e8d1e1
[MIG] product_code_unique: Migration to 16.0
marielejeune Sep 21, 2022
69886df
[UPD] Update product_code_unique.pot
Oct 19, 2022
ec17667
[UPD] README.rst
OCA-git-bot Oct 19, 2022
7099e41
Update translation files
weblate Oct 19, 2022
82e7894
Translated using Weblate (German)
marylla Nov 4, 2022
c8c40db
Added translation using Weblate (Italian)
PicchiSeba Apr 27, 2023
d3929b0
Translated using Weblate (Italian)
PicchiSeba Apr 27, 2023
8728095
Added translation using Weblate (Portuguese)
pedrocs-exo Jul 12, 2023
1ca66f7
Translated using Weblate (Portuguese)
pedrocs-exo Jul 12, 2023
a1b84fc
[UPD] README.rst
OCA-git-bot Sep 3, 2023
be8f86f
[IMP] product_code_unique: test performance improvement
josep-tecnativa Oct 23, 2023
7b1abf7
[BOT] post-merge updates
OCA-git-bot Oct 30, 2023
878d604
Translated using Weblate (Italian)
mymage Nov 1, 2023
9b55fcf
Added translation using Weblate (Spanish)
Ivorra78 Dec 29, 2023
1406111
Translated using Weblate (Spanish)
Ivorra78 Dec 29, 2023
69a9090
[MIG] product_code_unique: pre-commit
astirpe Mar 29, 2024
ed35c43
[MIG] product_code_unique: migrate to V17
astirpe Mar 29, 2024
37369e9
[UPD] Update product_code_unique.pot
Jul 19, 2024
e90f67e
[BOT] post-merge updates
OCA-git-bot Jul 19, 2024
53ccb14
[18.0][MIG] product_code_unique
psugne Jan 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions product_code_unique/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
=================================
Unique Product Internal Reference
=================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:9e0d608757e663ba1ac9605b6f3947b48da01b80dd8d2abacd92db4c7116608b
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fproduct--attribute-lightgray.png?logo=github
:target: https://github.com/OCA/product-attribute/tree/18.0/product_code_unique
:alt: OCA/product-attribute
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/product-attribute-18-0/product-attribute-18-0-product_code_unique
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/product-attribute&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module adds a constraint on the internal reference of the product
to make it unique across the database.

**Table of contents**

.. contents::
:local:

Usage
=====

- Unable to save a product when a new internal reference or default_code
value is the same with an existing record.
- A pre_init_hook process is initiated when there exist records without
an internal reference(default_code). A default value is generated to
populate empty field as a temporary value.

Known issues / Roadmap
======================

- Avoid duplicate warnings. Odoo has a warning for duplicate "Internal
Reference" of its own (it doesn't block from saving). Now both
warnings are displayed when trying to save a duplicate "Internal
Reference".

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/product-attribute/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/product-attribute/issues/new?body=module:%20product_code_unique%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Open Source Integrators

Contributors
------------

- Antonio Yamuta <ayamuta@opensourceintegrators.com>
- Raf Ven <raf.ven@dynapps.be>
- Watthanun Khorchai <watthanun_t@hotmail.com>
- Nedas Žilinskas <nedas.zilinskas@web-veistamo.fi>
- Ugnė Sinkevičienė <ugne@versada.eu>

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/product-attribute <https://github.com/OCA/product-attribute/tree/18.0/product_code_unique>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
5 changes: 5 additions & 0 deletions product_code_unique/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright (C) 2018 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
from .hook import pre_init_product_code
15 changes: 15 additions & 0 deletions product_code_unique/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (C) 2018 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Unique Product Internal Reference",
"summary": "Set Product Internal Reference as Unique",
"version": "18.0.1.0.0",
"license": "AGPL-3",
"author": "Open Source Integrators, Odoo Community Association (OCA)",
"category": "Product",
"website": "https://github.com/OCA/product-attribute",
"depends": ["product"],
"pre_init_hook": "pre_init_product_code",
"installable": True,
}
19 changes: 19 additions & 0 deletions product_code_unique/hook.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright (C) 2019 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).


def pre_init_product_code(env):
env.cr.execute(
"""UPDATE product_product
SET default_code = 'DEFAULT' || nextval('ir_default_id_seq')
WHERE id in (SELECT distinct(pp.id)
FROM product_product pp
INNER JOIN (SELECT default_code, COUNT(*)
FROM product_product
GROUP BY default_code
HAVING COUNT(*)>1
)pp1 on pp.default_code=pp1.default_code
or pp.default_code is NULL
or LENGTH(pp.default_code) = 0)"""
)
return True
30 changes: 30 additions & 0 deletions product_code_unique/i18n/ca.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_code_unique
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2022-04-22 10:05+0000\n"
"Last-Translator: pablontura <pablo.ruiz@qubiq.es>\n"
"Language-Team: none\n"
"Language: ca\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.3.2\n"

#. module: product_code_unique
#: model:ir.model.constraint,message:product_code_unique.constraint_product_product_default_code_uniq
msgid "Internal Reference must be unique across the database!"
msgstr "La referència interna ha de ser única a tota la base de dades!"

#. module: product_code_unique
#: model:ir.model,name:product_code_unique.model_product_product
msgid "Product Variant"
msgstr ""

#~ msgid "Product"
#~ msgstr "Producte"
31 changes: 31 additions & 0 deletions product_code_unique/i18n/de.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_code_unique
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2022-11-04 14:44+0000\n"
"Last-Translator: Maria Sparenberg <maria.sparenberg@gmx.net>\n"
"Language-Team: none\n"
"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.14.1\n"

#. module: product_code_unique
#: model:ir.model.constraint,message:product_code_unique.constraint_product_product_default_code_uniq
msgid "Internal Reference must be unique across the database!"
msgstr ""
"Die Interne Referenz muss eindeutig sein, Duplikate sind nicht zugelassen!"

#. module: product_code_unique
#: model:ir.model,name:product_code_unique.model_product_product
msgid "Product Variant"
msgstr "Produktvariante"

#~ msgid "Product"
#~ msgstr "Produkt"
27 changes: 27 additions & 0 deletions product_code_unique/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_code_unique
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-12-29 11:34+0000\n"
"Last-Translator: Ivorra78 <informatica@totmaterial.es>\n"
"Language-Team: none\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: product_code_unique
#: model:ir.model.constraint,message:product_code_unique.constraint_product_product_default_code_uniq
msgid "Internal Reference must be unique across the database!"
msgstr "¡La Referencia Interna debe ser única en toda la base de datos!"

#. module: product_code_unique
#: model:ir.model,name:product_code_unique.model_product_product
msgid "Product Variant"
msgstr "Variante del Producto"
36 changes: 36 additions & 0 deletions product_code_unique/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_code_unique
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2021-04-10 11:46+0000\n"
"Last-Translator: Yves Le Doeuff <yld@alliasys.fr>\n"
"Language-Team: none\n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n > 1;\n"
"X-Generator: Weblate 4.3.2\n"

#. module: product_code_unique
#: model:ir.model.constraint,message:product_code_unique.constraint_product_product_default_code_uniq
msgid "Internal Reference must be unique across the database!"
msgstr "La référence interne doit être unique !"

#. module: product_code_unique
#: model:ir.model,name:product_code_unique.model_product_product
msgid "Product Variant"
msgstr ""

#~ msgid "Display Name"
#~ msgstr "Nom affiché"

#~ msgid "Last Modified on"
#~ msgstr "Dernière modification"

#~ msgid "Product"
#~ msgstr "Article"
36 changes: 36 additions & 0 deletions product_code_unique/i18n/fr_FR.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_code_unique
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2021-04-10 15:46+0000\n"
"Last-Translator: Yves Le Doeuff <yld@alliasys.fr>\n"
"Language-Team: none\n"
"Language: fr_FR\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n > 1;\n"
"X-Generator: Weblate 4.3.2\n"

#. module: product_code_unique
#: model:ir.model.constraint,message:product_code_unique.constraint_product_product_default_code_uniq
msgid "Internal Reference must be unique across the database!"
msgstr "La référence interne doit être unique !"

#. module: product_code_unique
#: model:ir.model,name:product_code_unique.model_product_product
msgid "Product Variant"
msgstr ""

#~ msgid "Display Name"
#~ msgstr "Nom affiché"

#~ msgid "Last Modified on"
#~ msgstr "Dernière modification"

#~ msgid "Product"
#~ msgstr "Article"
27 changes: 27 additions & 0 deletions product_code_unique/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_code_unique
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-11-01 12:37+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: product_code_unique
#: model:ir.model.constraint,message:product_code_unique.constraint_product_product_default_code_uniq
msgid "Internal Reference must be unique across the database!"
msgstr "Il riferimento interno deve essere unico all'interno del database!"

#. module: product_code_unique
#: model:ir.model,name:product_code_unique.model_product_product
msgid "Product Variant"
msgstr "Variante prodotto"
24 changes: 24 additions & 0 deletions product_code_unique/i18n/product_code_unique.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_code_unique
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 18.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: product_code_unique
#: model:ir.model.constraint,message:product_code_unique.constraint_product_product_default_code_uniq
msgid "Internal Reference must be unique across the database!"
msgstr ""

#. module: product_code_unique
#: model:ir.model,name:product_code_unique.model_product_product
msgid "Product Variant"
msgstr ""
27 changes: 27 additions & 0 deletions product_code_unique/i18n/pt.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_code_unique
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-07-13 00:11+0000\n"
"Last-Translator: Pedro Castro Silva <pedrocs@exo.pt>\n"
"Language-Team: none\n"
"Language: pt\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n > 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: product_code_unique
#: model:ir.model.constraint,message:product_code_unique.constraint_product_product_default_code_uniq
msgid "Internal Reference must be unique across the database!"
msgstr "A Referência Interna tem que ser única na base de dados!"

#. module: product_code_unique
#: model:ir.model,name:product_code_unique.model_product_product
msgid "Product Variant"
msgstr "Variante de Produto"
4 changes: 4 additions & 0 deletions product_code_unique/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright (C) 2018 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import product
Loading
Loading