Skip to content

Commit

Permalink
Merge PR #1568 into 17.0
Browse files Browse the repository at this point in the history
Signed-off-by gurneyalex
  • Loading branch information
OCA-git-bot committed Jul 19, 2024
2 parents 7a06ead + bddc095 commit 488e9c5
Show file tree
Hide file tree
Showing 23 changed files with 890 additions and 0 deletions.
97 changes: 97 additions & 0 deletions product_code_unique/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
=================================
Unique Product Internal Reference
=================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:0ddeb0b9117bb302c5a68a2dda8c822ed2138d1ba8088082b2443fa10dfd2e6e
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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/17.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-17-0/product-attribute-17-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=17.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:%2017.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 <[email protected]>
- Raf Ven <[email protected]>
- Watthanun Khorchai <[email protected]>
- Nedas Žilinskas <[email protected]>

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/17.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": "17.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 <[email protected]>\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 <[email protected]>\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 <[email protected]>\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 <[email protected]>\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 <[email protected]>\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 <[email protected]>\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 16.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 <[email protected]>\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

0 comments on commit 488e9c5

Please sign in to comment.