diff --git a/product_code_unique/README.rst b/product_code_unique/README.rst new file mode 100644 index 00000000000..d39d2cf8b8e --- /dev/null +++ b/product_code_unique/README.rst @@ -0,0 +1,61 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +================================== +Unique Product Internal Reference +================================== + +This module adds a constraint on the internal reference of the product +to make it unique across the database. + +Usage +===== + +* For this module to be succesfully installed, there should be no 2 existing +records that has the same Internal Reference including empty fields. A +correction of the records needs to be done prior to the installation of this +module. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smash it by providing detailed and welcomed feedback. + +Credits +======= + +Images +------ + +* Odoo Community Association: `Icon `_. + +Contributors +------------ + +* Antonio Yamuta + +Funders +------- + +The development of this module has been financially supported by: + +* Open Source Integrators + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +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. + +To contribute to this module, please visit https://odoo-community.org. diff --git a/product_code_unique/__init__.py b/product_code_unique/__init__.py new file mode 100644 index 00000000000..631bd4893aa --- /dev/null +++ b/product_code_unique/__init__.py @@ -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 models diff --git a/product_code_unique/__manifest__.py b/product_code_unique/__manifest__.py new file mode 100644 index 00000000000..1002b81557c --- /dev/null +++ b/product_code_unique/__manifest__.py @@ -0,0 +1,19 @@ +# 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": "11.0.1.0.0", + "license": "AGPL-3", + "author": "Open Source Integrators, Odoo Community Association (OCA)", + "category": "Product", + "website": "http://www.opensourceintegrators.com", + "depends": ["product"], + "data": [ + ], + 'demo': [ + 'data/product_demo.xml', + ], + "installable": True, +} diff --git a/product_code_unique/data/product_demo.xml b/product_code_unique/data/product_demo.xml new file mode 100644 index 00000000000..38424a4ca2f --- /dev/null +++ b/product_code_unique/data/product_demo.xml @@ -0,0 +1,40 @@ + + + + GAP Analysis Service + GAPANA + + + Support Services + SUSER + + + Parts Replacement + PAREP + + + Repair + REP + + + Cleaning + CLEN + + + Whiteboard + WTBO + + + + Gold Membership + GMEM + + + Silver Membership + SMEM + + + Basic Membership + BMEM + + diff --git a/product_code_unique/models/__init__.py b/product_code_unique/models/__init__.py new file mode 100644 index 00000000000..2c3319d8df1 --- /dev/null +++ b/product_code_unique/models/__init__.py @@ -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 diff --git a/product_code_unique/models/product.py b/product_code_unique/models/product.py new file mode 100644 index 00000000000..09777166f2c --- /dev/null +++ b/product_code_unique/models/product.py @@ -0,0 +1,24 @@ +# Copyright (C) 2018 - TODAY, Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class ProductTemplate(models.Model): + _inherit = 'product.template' + + default_code = fields.Char('Internal Reference', index=True) + + _sql_constraints = [ + ('product_template_default_code_uniq', 'unique(default_code)', + 'Internal Reference must be unique across the database!')] + + +class ProductProduct(models.Model): + _inherit = 'product.product' + + default_code = fields.Char('Internal Reference', index=True) + + _sql_constraints = [ + ('product_product_default_code_uniq', 'unique(default_code)', + 'Internal Reference must be unique across the database!')] diff --git a/product_code_unique/static/description/icon.png b/product_code_unique/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/product_code_unique/static/description/icon.png differ