diff --git a/product_tags_code/README.rst b/product_tags_code/README.rst new file mode 100644 index 00000000000..012c5193528 --- /dev/null +++ b/product_tags_code/README.rst @@ -0,0 +1,108 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +================= +Product Tags Code +================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:a822c71ca50086cfa548efbc4e9f80219d80e7f00a11af90232071af7577bc81 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/license-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/19.0/product_tags_code + :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-19-0/product-attribute-19-0-product_tags_code + :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=19.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Allows to reference tag records through a unique code. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +To configure this module, you need to: + +1. Go to the product form view. +2. Create and edit tags using the form view + +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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Camptocamp SA + +Contributors +------------ + +- Thomas Nowicki + +- Simone Orsi + +- [Trobz] (`https://trobz.com/ `__): + + - Dung Tran + - Khoi (Kien Kim) + +Other credits +------------- + +The migration of this module from 14.0 to 18.0 was financially supported +by: + +- Camptocamp + +The migration of this module from 18.0 to 19.0 was financially supported +by: + +- PLEDRA NETCOM S.R.L + +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 `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/product_tags_code/__init__.py b/product_tags_code/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/product_tags_code/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/product_tags_code/__manifest__.py b/product_tags_code/__manifest__.py new file mode 100644 index 00000000000..abdcb71cd38 --- /dev/null +++ b/product_tags_code/__manifest__.py @@ -0,0 +1,13 @@ +# Copyright 2020 Camptocamp +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Product Tags Code", + "summary": "This addon allow to add code on products tags", + "version": "19.0.1.0.0", + "license": "AGPL-3", + "author": "Camptocamp SA, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/product-attribute", + "depends": ["product"], + "data": ["views/product_tag_views.xml"], +} diff --git a/product_tags_code/i18n/es.po b/product_tags_code/i18n/es.po new file mode 100644 index 00000000000..cc8ee6b09b5 --- /dev/null +++ b/product_tags_code/i18n/es.po @@ -0,0 +1,47 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_template_tags_code +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-01-15 16:36+0000\n" +"Last-Translator: Ivorra78 \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_template_tags_code +#: model:ir.model.fields,field_description:product_template_tags_code.field_product_template_tag__code +msgid "Code" +msgstr "Código" + +#. module: product_template_tags_code +#: model:ir.model.fields,field_description:product_template_tags_code.field_product_template_tag__display_name +msgid "Display Name" +msgstr "Mostrar Nombre" + +#. module: product_template_tags_code +#: model:ir.model.fields,field_description:product_template_tags_code.field_product_template_tag__id +msgid "ID" +msgstr "ID" + +#. module: product_template_tags_code +#: model:ir.model.fields,field_description:product_template_tags_code.field_product_template_tag____last_update +msgid "Last Modified on" +msgstr "Última Modificación el" + +#. module: product_template_tags_code +#: model:ir.model,name:product_template_tags_code.model_product_template_tag +msgid "Product Tag" +msgstr "Etiqueta de producto" + +#. module: product_template_tags_code +#: model:ir.model.constraint,message:product_template_tags_code.constraint_product_template_tag_code_uniq +msgid "Product template tag code already exists" +msgstr "El código de etiqueta de la plantilla de producto ya existe" diff --git a/product_tags_code/i18n/it.po b/product_tags_code/i18n/it.po new file mode 100644 index 00000000000..f3e896dec53 --- /dev/null +++ b/product_tags_code/i18n/it.po @@ -0,0 +1,47 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_template_tags_code +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-11-06 08:37+0000\n" +"Last-Translator: mymage \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_template_tags_code +#: model:ir.model.fields,field_description:product_template_tags_code.field_product_template_tag__code +msgid "Code" +msgstr "Codice" + +#. module: product_template_tags_code +#: model:ir.model.fields,field_description:product_template_tags_code.field_product_template_tag__display_name +msgid "Display Name" +msgstr "Nome visualizzato" + +#. module: product_template_tags_code +#: model:ir.model.fields,field_description:product_template_tags_code.field_product_template_tag__id +msgid "ID" +msgstr "ID" + +#. module: product_template_tags_code +#: model:ir.model.fields,field_description:product_template_tags_code.field_product_template_tag____last_update +msgid "Last Modified on" +msgstr "Ultima modifica il" + +#. module: product_template_tags_code +#: model:ir.model,name:product_template_tags_code.model_product_template_tag +msgid "Product Tag" +msgstr "Etichetta prodotto" + +#. module: product_template_tags_code +#: model:ir.model.constraint,message:product_template_tags_code.constraint_product_template_tag_code_uniq +msgid "Product template tag code already exists" +msgstr "Codice etichetta modello prodotto già esistente" diff --git a/product_tags_code/i18n/product_tags_code.pot b/product_tags_code/i18n/product_tags_code.pot new file mode 100644 index 00000000000..9f000ac7250 --- /dev/null +++ b/product_tags_code/i18n/product_tags_code.pot @@ -0,0 +1,29 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_tags_code +# +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_tags_code +#: model:ir.model.fields,field_description:product_tags_code.field_product_tag__code +msgid "Code" +msgstr "" + +#. module: product_tags_code +#: model:ir.model,name:product_tags_code.model_product_tag +msgid "Product Tag" +msgstr "" + +#. module: product_tags_code +#: model:ir.model.constraint,message:product_tags_code.constraint_product_tag_code_uniq +msgid "Product template tag code already exists" +msgstr "" diff --git a/product_tags_code/models/__init__.py b/product_tags_code/models/__init__.py new file mode 100644 index 00000000000..9eeecb86d32 --- /dev/null +++ b/product_tags_code/models/__init__.py @@ -0,0 +1 @@ +from . import product_tag diff --git a/product_tags_code/models/product_tag.py b/product_tags_code/models/product_tag.py new file mode 100644 index 00000000000..c12a2a8c625 --- /dev/null +++ b/product_tags_code/models/product_tag.py @@ -0,0 +1,32 @@ +# Copyright 2020 Camptocamp +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class ProductTag(models.Model): + _inherit = "product.tag" + + code = fields.Char( + compute="_compute_code", + readonly=False, + inverse="_inverse_code", + store=True, + ) + + _code_uniq = models.Constraint( + "unique (code)", + "Product template tag code already exists", + ) + + @api.depends("name", "code") + def _compute_code(self): + for rec in self: + if rec.name and rec.name.strip(): + rec.code = self.env["ir.http"]._slugify(rec.name) + else: + rec.code = "" + + def _inverse_code(self): + for rec in self: + rec.code = self.env["ir.http"]._slugify(rec.code) diff --git a/product_tags_code/pyproject.toml b/product_tags_code/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/product_tags_code/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/product_tags_code/readme/CONFIGURE.md b/product_tags_code/readme/CONFIGURE.md new file mode 100644 index 00000000000..626c16a4866 --- /dev/null +++ b/product_tags_code/readme/CONFIGURE.md @@ -0,0 +1,4 @@ +To configure this module, you need to: + +1. Go to the product form view. +2. Create and edit tags using the form view diff --git a/product_tags_code/readme/CONTRIBUTORS.md b/product_tags_code/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..5cb808664d5 --- /dev/null +++ b/product_tags_code/readme/CONTRIBUTORS.md @@ -0,0 +1,6 @@ +- Thomas Nowicki \<\> +- Simone Orsi \<\> + +- [Trobz] (https://trobz.com/): + - Dung Tran \<\> + - Khoi (Kien Kim) \<\> diff --git a/product_tags_code/readme/CREDITS.md b/product_tags_code/readme/CREDITS.md new file mode 100644 index 00000000000..ddad62b9483 --- /dev/null +++ b/product_tags_code/readme/CREDITS.md @@ -0,0 +1,7 @@ +The migration of this module from 14.0 to 18.0 was financially supported by: + +- Camptocamp + +The migration of this module from 18.0 to 19.0 was financially supported by: + +- PLEDRA NETCOM S.R.L diff --git a/product_tags_code/readme/DESCRIPTION.md b/product_tags_code/readme/DESCRIPTION.md new file mode 100644 index 00000000000..a78f1913bec --- /dev/null +++ b/product_tags_code/readme/DESCRIPTION.md @@ -0,0 +1 @@ +Allows to reference tag records through a unique code. diff --git a/product_tags_code/static/description/icon.png b/product_tags_code/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/product_tags_code/static/description/icon.png differ diff --git a/product_tags_code/static/description/index.html b/product_tags_code/static/description/index.html new file mode 100644 index 00000000000..5d437e0dbc7 --- /dev/null +++ b/product_tags_code/static/description/index.html @@ -0,0 +1,458 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Product Tags Code

+ +

Beta License: AGPL-3 OCA/product-attribute Translate me on Weblate Try me on Runboat

+

Allows to reference tag records through a unique code.

+

Table of contents

+ +
+

Configuration

+

To configure this module, you need to:

+
    +
  1. Go to the product form view.
  2. +
  3. Create and edit tags using the form view
  4. +
+
+
+

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 to smash it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Camptocamp SA
  • +
+
+
+

Contributors

+ +
+
+

Other credits

+

The migration of this module from 14.0 to 18.0 was financially supported +by:

+
    +
  • Camptocamp
  • +
+

The migration of this module from 18.0 to 19.0 was financially supported +by:

+
    +
  • PLEDRA NETCOM S.R.L
  • +
+
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

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 project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+
+ + diff --git a/product_tags_code/tests/__init__.py b/product_tags_code/tests/__init__.py new file mode 100644 index 00000000000..3d700ed3b3b --- /dev/null +++ b/product_tags_code/tests/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2020 Camptocamp +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import test_product_tags_code diff --git a/product_tags_code/tests/test_product_tags_code.py b/product_tags_code/tests/test_product_tags_code.py new file mode 100644 index 00000000000..9ee56ba4ce7 --- /dev/null +++ b/product_tags_code/tests/test_product_tags_code.py @@ -0,0 +1,48 @@ +# Copyright 2020 Camptocamp +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import Command + +from odoo.addons.base.tests.common import BaseCommon + + +class TestProductTagsCode(BaseCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.product_tmpl = cls.env["product.template"].create({"name": "Test Product"}) + + def test_product_tags_code(self): + product_tag = self.env["product.tag"].create( + { + "name": "Test Tag", + "product_template_ids": [Command.set([self.product_tmpl.id])], + } + ) + self.assertEqual(product_tag.code, "test-tag") + + def test_product_tags_code_writable(self): + product_tag = self.env["product.tag"].create( + { + "name": "Test Tag", + "code": "foo tag !!", + "product_template_ids": [Command.set([self.product_tmpl.id])], + } + ) + self.assertEqual(product_tag.code, "foo-tag") + product_tag.write({"code": "test tag writable"}) + self.assertEqual(product_tag.code, "test-tag-writable") + product_tag.write({"name": "test tag name 2"}) + self.assertEqual(product_tag.code, "test-tag-name-2") + + def test_product_multi_tags(self): + prods_data = [] + for x in range(3): + prods_data.append( + { + "name": f"YO{x}", + "product_template_ids": [Command.set([self.product_tmpl.id])], + } + ) + prods = self.env["product.tag"].create(prods_data) + self.assertEqual(prods.mapped("code"), ["yo0", "yo1", "yo2"]) diff --git a/product_tags_code/views/product_tag_views.xml b/product_tags_code/views/product_tag_views.xml new file mode 100644 index 00000000000..f0763dbf5ef --- /dev/null +++ b/product_tags_code/views/product_tag_views.xml @@ -0,0 +1,24 @@ + + + + product.tag.form.view.inherit + product.tag + + + + + + + + + product.tag.tree.view.inherit + product.tag + + + + + + + +