diff --git a/product_brand_tag/README.rst b/product_brand_tag/README.rst new file mode 100644 index 000000000..0f3950226 --- /dev/null +++ b/product_brand_tag/README.rst @@ -0,0 +1,81 @@ +================== +Product brand tags +================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:a5889687ea63d9c43deb386bd3c8143a591445b9d915d4742b63d4eaad7e938a + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fbrand-lightgray.png?logo=github + :target: https://github.com/OCA/brand/tree/17.0/product_brand_tag + :alt: OCA/brand +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/brand-17-0/brand-17-0-product_brand_tag + :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/brand&target_branch=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Add tags to product brands. + +Inspired by product_template_tags by ACSONE. + +**Table of contents** + +.. contents:: + :local: + +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 + +Contributors +------------ + +- Simone Orsi +- `Heliconia Solutions Pvt. Ltd. `__ + + - Bhavesh Heliconia + +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/brand `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/product_brand_tag/__init__.py b/product_brand_tag/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/product_brand_tag/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/product_brand_tag/__manifest__.py b/product_brand_tag/__manifest__.py new file mode 100644 index 000000000..1f5e4239d --- /dev/null +++ b/product_brand_tag/__manifest__.py @@ -0,0 +1,21 @@ +# Copyright 2021 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +{ + "name": "Product brand tags", + "summary": "Add tags to product brand", + "version": "17.0.1.0.0", + "author": "Camptocamp, Odoo Community Association (OCA)", + "license": "AGPL-3", + "category": "Product", + "depends": [ + "product_brand", + ], + "website": "https://github.com/OCA/brand", + "data": [ + "security/ir.model.access.csv", + "security/ir_rule.xml", + "views/product_brand_view.xml", + "views/product_brand_tag_view.xml", + ], + "installable": True, +} diff --git a/product_brand_tag/i18n/es.po b/product_brand_tag/i18n/es.po new file mode 100644 index 000000000..8e7c806fd --- /dev/null +++ b/product_brand_tag/i18n/es.po @@ -0,0 +1,129 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_brand_tag +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-10-28 13:24+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_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag__brands_count +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag_mixin__brands_count +msgid "# of brands" +msgstr "# de marcas" + +#. module: product_brand_tag +#: model:ir.actions.act_window,name:product_brand_tag.action_product_brand_tags +msgid "Brand tags" +msgstr "Etiquetas de marca" + +#. module: product_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag__product_brand_ids +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag_mixin__product_brand_ids +msgid "Brands" +msgstr "Marcas" + +#. module: product_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag__code +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag_mixin__code +msgid "Code" +msgstr "Código" + +#. module: product_brand_tag +#: model_terms:ir.ui.view,arch_db:product_brand_tag.view_product_brand_tag_form +msgid "Color" +msgstr "Color" + +#. module: product_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag__color +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag_mixin__color +msgid "Color Index" +msgstr "Índice de Color" + +#. module: product_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag__company_id +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag_mixin__company_id +msgid "Company" +msgstr "Compañía" + +#. module: product_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag__create_uid +msgid "Created by" +msgstr "Creado por" + +#. module: product_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag__create_date +msgid "Created on" +msgstr "Creado el" + +#. module: product_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag__display_name +msgid "Display Name" +msgstr "Mostrar Nombre" + +#. module: product_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag__id +msgid "ID" +msgstr "ID(identificación)" + +#. module: product_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag____last_update +msgid "Last Modified on" +msgstr "Última Modificación el" + +#. module: product_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag__write_uid +msgid "Last Updated by" +msgstr "Actualizado por Última vez por" + +#. module: product_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag__write_date +msgid "Last Updated on" +msgstr "Última Actualización el" + +#. module: product_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag__name +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag_mixin__name +msgid "Name" +msgstr "Nombre" + +#. module: product_brand_tag +#: model:ir.model,name:product_brand_tag.model_product_brand +msgid "Product Brand" +msgstr "Marca de Producto" + +#. module: product_brand_tag +#: model:ir.model,name:product_brand_tag.model_product_brand_tag +msgid "Product Brand Tag" +msgstr "Etiqueta de Marca del Producto" + +#. module: product_brand_tag +#: model:ir.model,name:product_brand_tag.model_product_brand_tag_mixin +msgid "Product Brand Tag Mixin" +msgstr "Mezcla de Etiquetas de Marca de Producto" + +#. module: product_brand_tag +#: model:ir.ui.menu,name:product_brand_tag.menu_product_brand_tags +msgid "Product Brands Tags" +msgstr "Etiquetas de Marcas de Productos" + +#. module: product_brand_tag +#: model:ir.model.constraint,message:product_brand_tag.constraint_product_brand_tag_mixin_tag_code_uniq +#: model:ir.model.constraint,message:product_brand_tag.constraint_product_brand_tag_tag_code_uniq +msgid "Tag code must be unique inside a company" +msgstr "El código de etiqueta debe ser único dentro de una compañía" + +#. module: product_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand__tag_ids +msgid "Tags" +msgstr "Etiquetas" diff --git a/product_brand_tag/i18n/it.po b/product_brand_tag/i18n/it.po new file mode 100644 index 000000000..c8c64ca97 --- /dev/null +++ b/product_brand_tag/i18n/it.po @@ -0,0 +1,140 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_brand_tag +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-09-18 10:06+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 5.6.2\n" + +#. module: product_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag__brands_count +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag_mixin__brands_count +msgid "# of brands" +msgstr "# di marche" + +#. module: product_brand_tag +#: model:ir.actions.act_window,name:product_brand_tag.action_product_brand_tags +msgid "Brand tags" +msgstr "Etichette marche" + +#. module: product_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag_mixin__product_brand_ids +msgid "Brands" +msgstr "Marche" + +#. module: product_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag__code +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag_mixin__code +msgid "Code" +msgstr "Codice" + +#. module: product_brand_tag +#: model_terms:ir.ui.view,arch_db:product_brand_tag.view_product_brand_tag_form +msgid "Color" +msgstr "Colore" + +#. module: product_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag__color +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag_mixin__color +msgid "Color Index" +msgstr "Indice colore" + +#. module: product_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag__company_id +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag_mixin__company_id +msgid "Company" +msgstr "Azienda" + +#. module: product_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag__create_uid +msgid "Created by" +msgstr "Creato da" + +#. module: product_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag__create_date +msgid "Created on" +msgstr "Creato il" + +#. module: product_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand__display_name +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag__display_name +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag_mixin__display_name +msgid "Display Name" +msgstr "Nome visualizzato" + +#. module: product_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand__id +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag__id +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag_mixin__id +msgid "ID" +msgstr "ID" + +#. module: product_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand____last_update +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag____last_update +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag_mixin____last_update +msgid "Last Modified on" +msgstr "Ultima modifica il" + +#. module: product_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag__write_uid +msgid "Last Updated by" +msgstr "Ultimo aggiornamento di" + +#. module: product_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag__write_date +msgid "Last Updated on" +msgstr "Ultimo aggiornamento il" + +#. module: product_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag__name +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag_mixin__name +msgid "Name" +msgstr "Nome" + +#. module: product_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand__tag_ids +msgid "Primary Tags" +msgstr "Etichette primarie" + +#. module: product_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag__product_brand_ids +msgid "Primary for brands" +msgstr "Primaria per marche" + +#. module: product_brand_tag +#: model:ir.model,name:product_brand_tag.model_product_brand +msgid "Product Brand" +msgstr "Marca del prodotto" + +#. module: product_brand_tag +#: model:ir.model,name:product_brand_tag.model_product_brand_tag +msgid "Product Brand Tag" +msgstr "Etichetta marca del prodotto" + +#. module: product_brand_tag +#: model:ir.model,name:product_brand_tag.model_product_brand_tag_mixin +msgid "Product Brand Tag Mixin" +msgstr "Mixin etichetta marca prodotto" + +#. module: product_brand_tag +#: model:ir.ui.menu,name:product_brand_tag.menu_product_brand_tags +msgid "Product Brands Tags" +msgstr "Etichette marche prodotto" + +#. module: product_brand_tag +#: model:ir.model.constraint,message:product_brand_tag.constraint_product_brand_tag_csr_tag_code_uniq +#: model:ir.model.constraint,message:product_brand_tag.constraint_product_brand_tag_mixin_tag_code_uniq +#: model:ir.model.constraint,message:product_brand_tag.constraint_product_brand_tag_tag_code_uniq +msgid "Tag code must be unique inside a company" +msgstr "Il codice dell'etichetta dev'essere univoca per la stessa azienda" diff --git a/product_brand_tag/i18n/product_brand_tag.pot b/product_brand_tag/i18n/product_brand_tag.pot new file mode 100644 index 000000000..39c689e2e --- /dev/null +++ b/product_brand_tag/i18n/product_brand_tag.pot @@ -0,0 +1,126 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_brand_tag +# +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_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag__brands_count +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag_mixin__brands_count +msgid "# of brands" +msgstr "" + +#. module: product_brand_tag +#: model:ir.actions.act_window,name:product_brand_tag.action_product_brand_tags +msgid "Brand tags" +msgstr "" + +#. module: product_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag__product_brand_ids +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag_mixin__product_brand_ids +msgid "Brands" +msgstr "" + +#. module: product_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag__code +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag_mixin__code +msgid "Code" +msgstr "" + +#. module: product_brand_tag +#: model_terms:ir.ui.view,arch_db:product_brand_tag.view_product_brand_tag_form +msgid "Color" +msgstr "" + +#. module: product_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag__color +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag_mixin__color +msgid "Color Index" +msgstr "" + +#. module: product_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag__company_id +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag_mixin__company_id +msgid "Company" +msgstr "" + +#. module: product_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag__create_uid +msgid "Created by" +msgstr "" + +#. module: product_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag__create_date +msgid "Created on" +msgstr "" + +#. module: product_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag__display_name +msgid "Display Name" +msgstr "" + +#. module: product_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag__id +msgid "ID" +msgstr "" + +#. module: product_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag____last_update +msgid "Last Modified on" +msgstr "" + +#. module: product_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: product_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag__write_date +msgid "Last Updated on" +msgstr "" + +#. module: product_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag__name +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand_tag_mixin__name +msgid "Name" +msgstr "" + +#. module: product_brand_tag +#: model:ir.model,name:product_brand_tag.model_product_brand +msgid "Product Brand" +msgstr "" + +#. module: product_brand_tag +#: model:ir.model,name:product_brand_tag.model_product_brand_tag +msgid "Product Brand Tag" +msgstr "" + +#. module: product_brand_tag +#: model:ir.model,name:product_brand_tag.model_product_brand_tag_mixin +msgid "Product Brand Tag Mixin" +msgstr "" + +#. module: product_brand_tag +#: model:ir.ui.menu,name:product_brand_tag.menu_product_brand_tags +msgid "Product Brands Tags" +msgstr "" + +#. module: product_brand_tag +#: model:ir.model.constraint,message:product_brand_tag.constraint_product_brand_tag_mixin_tag_code_uniq +#: model:ir.model.constraint,message:product_brand_tag.constraint_product_brand_tag_tag_code_uniq +msgid "Tag code must be unique inside a company" +msgstr "" + +#. module: product_brand_tag +#: model:ir.model.fields,field_description:product_brand_tag.field_product_brand__tag_ids +msgid "Tags" +msgstr "" diff --git a/product_brand_tag/models/__init__.py b/product_brand_tag/models/__init__.py new file mode 100644 index 000000000..734b03960 --- /dev/null +++ b/product_brand_tag/models/__init__.py @@ -0,0 +1,3 @@ +from . import product_brand +from . import product_brand_tag_mixin +from . import product_brand_tag diff --git a/product_brand_tag/models/product_brand.py b/product_brand_tag/models/product_brand.py new file mode 100644 index 000000000..bff841bdb --- /dev/null +++ b/product_brand_tag/models/product_brand.py @@ -0,0 +1,18 @@ +# Copyright 2021 Camptocamp SA +# @author: Simone Orsi +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + + +from odoo import fields, models + + +class ProductBrand(models.Model): + _inherit = "product.brand" + + tag_ids = fields.Many2many( + string="Tags", + comodel_name="product.brand.tag", + relation="product_brand_tag_rel", + column1="brand_id", + column2="tag_id", + ) diff --git a/product_brand_tag/models/product_brand_tag.py b/product_brand_tag/models/product_brand_tag.py new file mode 100644 index 000000000..4dd5599d1 --- /dev/null +++ b/product_brand_tag/models/product_brand_tag.py @@ -0,0 +1,13 @@ +# Copyright 2021 Camptocamp SA +# @author: Simone Orsi +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class ProductBrandTag(models.Model): + _name = "product.brand.tag" + _inherit = "product.brand.tag.mixin" + _description = "Product Brand Tag" + + product_brand_ids = fields.Many2many(relation="product_brand_tag_rel") diff --git a/product_brand_tag/models/product_brand_tag_mixin.py b/product_brand_tag/models/product_brand_tag_mixin.py new file mode 100644 index 000000000..26975793e --- /dev/null +++ b/product_brand_tag/models/product_brand_tag_mixin.py @@ -0,0 +1,75 @@ +# Copyright 2021 Camptocamp SA +# @author: Simone Orsi +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from psycopg2 import sql + +from odoo import api, fields, models + +from odoo.addons.http_routing.models.ir_http import slugify + + +class ProductBrandTag(models.AbstractModel): + _name = "product.brand.tag.mixin" + _description = "Product Brand Tag Mixin" + + name = fields.Char(required=True, translate=True) + code = fields.Char( + compute="_compute_code", inverse="_inverse_code", readonly=False, store=True + ) + color = fields.Integer(string="Color Index") + product_brand_ids = fields.Many2many( + comodel_name="product.brand", + string="Brands", + column1="tag_id", + column2="brand_id", + ) + brands_count = fields.Integer(string="# of brands", compute="_compute_brands_count") + company_id = fields.Many2one( + comodel_name="res.company", + string="Company", + default=lambda self: self.env.company.id, + ) + + _sql_constraints = [ + ( + "tag_code_uniq", + "unique(code, company_id)", + "Tag code must be unique inside a company", + ), + ] + + @api.depends("name") + def _compute_code(self): + for rec in self: + rec.code = slugify(rec.name) + + def _inverse_code(self): + for rec in self: + # Make sure is always normalized + rec.code = slugify(rec.code) + + @api.depends("product_brand_ids") + def _compute_brands_count(self): + count = self._get_brands_count("product_brand_ids") + for rec in self: + rec.brands_count = count.get(rec.id, 0) + + def _get_brands_count(self, rel_field_name): + res = {} + if self.ids: + field = self._fields[rel_field_name] + query = sql.SQL( + """ + SELECT {column1}, COUNT(*) + FROM {relation} + WHERE {column1} IN %s + GROUP BY {column1} + """ + ).format( + relation=sql.Identifier(field.relation), + column1=sql.Identifier(field.column1), + ) + self.env.cr.execute(query, (tuple(self.ids),)) + res = dict(self.env.cr.fetchall()) + return res diff --git a/product_brand_tag/pyproject.toml b/product_brand_tag/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/product_brand_tag/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/product_brand_tag/readme/CONTRIBUTORS.md b/product_brand_tag/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..e4eca4153 --- /dev/null +++ b/product_brand_tag/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- Simone Orsi \<\> +- [Heliconia Solutions Pvt. Ltd.](https://www.heliconia.io) + - Bhavesh Heliconia diff --git a/product_brand_tag/readme/DESCRIPTION.md b/product_brand_tag/readme/DESCRIPTION.md new file mode 100644 index 000000000..cd3fd73c4 --- /dev/null +++ b/product_brand_tag/readme/DESCRIPTION.md @@ -0,0 +1,3 @@ +Add tags to product brands. + +Inspired by product_template_tags by ACSONE. diff --git a/product_brand_tag/security/ir.model.access.csv b/product_brand_tag/security/ir.model.access.csv new file mode 100644 index 000000000..f08fed27f --- /dev/null +++ b/product_brand_tag/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_product_brand_tag_product_manager,product.brand.tag,model_product_brand_tag,base.group_partner_manager,1,1,1,1 +access_product_brand_tag_public,product.brand.tag.public,model_product_brand_tag,,1,0,0,0 diff --git a/product_brand_tag/security/ir_rule.xml b/product_brand_tag/security/ir_rule.xml new file mode 100644 index 000000000..8b7a65320 --- /dev/null +++ b/product_brand_tag/security/ir_rule.xml @@ -0,0 +1,15 @@ + + + + product.brand.tag company (product_brand_tags) + + + + + + + + ['|', ('company_id', '=', False), ('company_id', 'in', company_ids)] + + + diff --git a/product_brand_tag/static/description/icon.png b/product_brand_tag/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/product_brand_tag/static/description/icon.png differ diff --git a/product_brand_tag/static/description/index.html b/product_brand_tag/static/description/index.html new file mode 100644 index 000000000..afa058b9d --- /dev/null +++ b/product_brand_tag/static/description/index.html @@ -0,0 +1,428 @@ + + + + + +Product brand tags + + + +
+

Product brand tags

+ + +

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

+

Add tags to product brands.

+

Inspired by product_template_tags by ACSONE.

+

Table of contents

+ +
+

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
  • +
+
+
+

Contributors

+ +
+
+

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

+

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

+
+
+
+ + diff --git a/product_brand_tag/tests/__init__.py b/product_brand_tag/tests/__init__.py new file mode 100644 index 000000000..3b72ef1f2 --- /dev/null +++ b/product_brand_tag/tests/__init__.py @@ -0,0 +1 @@ +from . import test_product_brand diff --git a/product_brand_tag/tests/test_product_brand.py b/product_brand_tag/tests/test_product_brand.py new file mode 100644 index 000000000..d83f8b0b8 --- /dev/null +++ b/product_brand_tag/tests/test_product_brand.py @@ -0,0 +1,53 @@ +# Copyright 2021 Camptocamp SA +# @author: Simone Orsi +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + + +from psycopg2 import IntegrityError + +from odoo import Command +from odoo.tools import mute_logger + +from odoo.addons.product_brand.tests.common import CommonCase + + +class TestBrandTags(CommonCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.product_brand2 = cls.product_brand.copy({"name": "Test Brand 2"}) + cls.tag = cls.env["product.brand.tag"].create( + { + "name": "Test Tag", + "product_brand_ids": [ + Command.set([cls.product_brand.id, cls.product_brand2.id]) + ], + } + ) + + def test_brand_rel(self): + self.assertEqual(self.product_brand.tag_ids, self.tag) + self.assertEqual(self.product_brand2.tag_ids, self.tag) + + def test_count(self): + self.assertEqual(self.tag.brands_count, 2) + self.tag.product_brand_ids -= self.product_brand2 + self.assertEqual(self.tag.brands_count, 1) + + def test_code(self): + self.assertEqual(self.tag.code, "test-tag") + self.tag.code = "SomeThing wëird!" + self.assertEqual(self.tag.code, "something-weird") + + @mute_logger("odoo.sql_db") + def test_product_template_tag_uniq(self): + with self.assertRaises(IntegrityError): + with self.cr.savepoint(): + self.env["product.brand.tag"].create({"name": "Test Tag"}) + + self.env["product.brand.tag"].create( + { + "name": "Test Tag", + "company_id": self.env.company.create({"name": "Foo"}).id, + } + ) diff --git a/product_brand_tag/views/product_brand_tag_view.xml b/product_brand_tag/views/product_brand_tag_view.xml new file mode 100644 index 000000000..7d09c9581 --- /dev/null +++ b/product_brand_tag/views/product_brand_tag_view.xml @@ -0,0 +1,57 @@ + + + + + product.brand.tag.tree + product.brand.tag + + + + + + + + + + + + product.brand.tag.form + product.brand.tag + +
+ +
+
+ + + + + + + +
+
+
+
+ + + Brand tags + product.brand.tag + tree + + + + +
diff --git a/product_brand_tag/views/product_brand_view.xml b/product_brand_tag/views/product_brand_view.xml new file mode 100644 index 000000000..f57211938 --- /dev/null +++ b/product_brand_tag/views/product_brand_view.xml @@ -0,0 +1,29 @@ + + + + product.brand.search.form + product.brand + + + + + + + + + + product.brand.form + product.brand + + + + + + + + +