Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[18.0][MIG] product_code_unique: Migration to 18.0 #1769

Open
wants to merge 42 commits into
base: 18.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
d84d88d
[ADD] Module to add a constraint on the internal reference of the pro…
agyamuta Feb 28, 2018
0e39879
[UPD] Update product_code_unique.pot
oca-travis Jun 21, 2018
ea6badb
[MIG]product_code_unique: migration from 11 to 12
bizzappdev Nov 25, 2018
b5d50f4
[MIG] product_code_unique: Migration to 13.0
rven Oct 1, 2019
6b58cfc
[UPD] Update product_code_unique.pot
oca-travis Oct 7, 2019
8286708
[UPD] README.rst
OCA-git-bot Oct 7, 2019
cfcc1f6
pre-commit, black, isort
OCA-git-bot Oct 12, 2019
d000dc5
[MIG] product_supplierinfo_for_customer: Migration to v13.0
sergio-teruel Feb 4, 2020
9d9aec2
[13.0][FIXUP] .isort.cfg
HviorForgeFlow Feb 26, 2020
26c3fe2
[MIG] product_code_unique: Migration to 14.0
watthanun Nov 10, 2020
7e7dcb3
[UPD] Update product_code_unique.pot
oca-travis Nov 17, 2020
90162cd
[UPD] README.rst
OCA-git-bot Nov 17, 2020
cbc247a
Added translation using Weblate (French)
Yvesldff Apr 10, 2021
320570a
Translated using Weblate (French)
Yvesldff Apr 10, 2021
1a91821
Added translation using Weblate (French (France))
Yvesldff Apr 10, 2021
13ecc61
Translated using Weblate (French (France))
Yvesldff Apr 10, 2021
670abe4
[MIG] product_code_unique: Migration to 15.0
Jan 24, 2022
1360ba3
Added translation using Weblate (Catalan)
pablontura Apr 22, 2022
815d039
Translated using Weblate (Catalan)
pablontura Apr 22, 2022
a1166e2
Added translation using Weblate (German)
Apr 28, 2022
574a8b4
Translated using Weblate (German)
Apr 28, 2022
94d11c0
[MIG] product_code_unique: Migration to 16.0
marielejeune Sep 21, 2022
e22d1b9
[UPD] Update product_code_unique.pot
Oct 19, 2022
c1f3510
[UPD] README.rst
OCA-git-bot Oct 19, 2022
0412ed7
Update translation files
weblate Oct 19, 2022
c9a3258
Translated using Weblate (German)
marylla Nov 4, 2022
9c7bf25
Added translation using Weblate (Italian)
PicchiSeba Apr 27, 2023
d1b3ce1
Translated using Weblate (Italian)
PicchiSeba Apr 27, 2023
25254de
Added translation using Weblate (Portuguese)
pedrocs-exo Jul 12, 2023
37236fc
Translated using Weblate (Portuguese)
pedrocs-exo Jul 12, 2023
ccab2c9
[UPD] README.rst
OCA-git-bot Sep 3, 2023
a8929c2
[IMP] product_code_unique: test performance improvement
josep-tecnativa Oct 23, 2023
44266b0
[BOT] post-merge updates
OCA-git-bot Oct 30, 2023
dea7062
Translated using Weblate (Italian)
mymage Nov 1, 2023
7e4e5fa
Added translation using Weblate (Spanish)
Ivorra78 Dec 29, 2023
a76e75c
Translated using Weblate (Spanish)
Ivorra78 Dec 29, 2023
a5129d0
[MIG] product_code_unique: pre-commit
astirpe Mar 29, 2024
c22197f
[MIG] product_code_unique: migrate to V17
astirpe Mar 29, 2024
549ad85
[UPD] Update product_code_unique.pot
Jul 19, 2024
1c771b2
[BOT] post-merge updates
OCA-git-bot Jul 19, 2024
37ffc9f
[IMP] product_code_unique: pre-commit auto fixes
pfranck Nov 13, 2024
3da69b5
[MIG] product_code_unique: Migration to 18.0
pfranck Nov 13, 2024
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
17 changes: 17 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
services:
odoo:
image: odoo:18.0
ports:
- "8069:8069"
volumes:
- .:/mnt/extra-addons
- ./odoo.conf:/etc/odoo/odoo.conf
depends_on:
- db
db:
image: postgres:16
environment:
- POSTGRES_DB=postgres
- POSTGRES_USER=odoo
- POSTGRES_PASSWORD=odoo
- PGDATA=/var/lib/postgresql/data/pgdata
47 changes: 47 additions & 0 deletions odoo.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[options]
addons_path = /mnt/extra-addons
data_dir = /var/lib/odoo
; admin_passwd = admin
; csv_internal_sep = ,
; db_maxconn = 64
; db_name = erp
db_host = db
; dbfilter = erp
db_port = 5432
db_user = odoo
db_password = odoo
db_maxconn = 250
max_cron_threads = 2
server_wide_modules=web
; redis_session=True
; redis_host=sessions
; redis_port=6379
; db_template = template1
; dbfilter = .*
; debug_mode = False
; email_from = False
; limit_memory_hard = 268435456
; imit_memory_soft = 2147483648
; limit_request = 8192
limit_time_cpu = 600
limit_time_real = 1200
; list_db = True
; log_db = False
; log_handler = [':INFO']
; log_level = info
; logfile = None
; longpolling_port = 8072
; osv_memory_age_limit = 1.0
; osv_memory_count_limit = False
; smtp_password = False
; smtp_port = 25
; smtp_server = localhost
; smtp_ssl = False
; smtp_user = False
; workers = 0
; xmlrpc = True
; xmlrpc_interface =
; xmlrpc_port = 8069
; xmlrpcs = True
; xmlrpcs_interface =
; xmlrpcs_port = 8071
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: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 <[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/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 <[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"
Loading
Loading