diff --git a/mrp_tag/README.rst b/mrp_tag/README.rst new file mode 100644 index 00000000000..76640aa71f0 --- /dev/null +++ b/mrp_tag/README.rst @@ -0,0 +1,83 @@ +======== +MRP Tags +======== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:b1286b744697667cb4aea4d9d615127f0a9032ebc94617e9b5b82d3815d121d9 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fmanufacture-lightgray.png?logo=github + :target: https://github.com/OCA/manufacture/tree/18.0/mrp_tag + :alt: OCA/manufacture +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/manufacture-18-0/manufacture-18-0-mrp_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/manufacture&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to add multiple tags to Manufacturing Orders + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use this module, you need to go to Manufacture Order and select tag. + +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 +------- + +* ForgeFlow + +Contributors +------------ + +- Jasmin Solanki +- Arturo Arribas +- Heliconia Solutions Pvt. Ltd. + +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/manufacture `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/mrp_tag/__init__.py b/mrp_tag/__init__.py new file mode 100644 index 00000000000..4b76c7b2d5c --- /dev/null +++ b/mrp_tag/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import models diff --git a/mrp_tag/__manifest__.py b/mrp_tag/__manifest__.py new file mode 100644 index 00000000000..0dbf11bda4f --- /dev/null +++ b/mrp_tag/__manifest__.py @@ -0,0 +1,21 @@ +# Copyright 2022 ForgeFlow S.L. +# (http://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +{ + "name": "MRP Tags", + "summary": "Allows to add multiple tags to Manufacturing Orders", + "version": "18.0.1.0.0", + "author": "ForgeFlow, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/manufacture", + "category": "Purchases", + "depends": ["mrp"], + "data": [ + "security/ir.model.access.csv", + "views/mrp_production_view.xml", + "views/mrp_tag_view.xml", + ], + "license": "AGPL-3", + "installable": True, + "application": False, +} diff --git a/mrp_tag/i18n/es.po b/mrp_tag/i18n/es.po new file mode 100644 index 00000000000..e7ac2af9b99 --- /dev/null +++ b/mrp_tag/i18n/es.po @@ -0,0 +1,115 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mrp_tag +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-03-25 21:33+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: mrp_tag +#: model:ir.model.fields,field_description:mrp_tag.field_mrp_tag__child_ids +msgid "Child" +msgstr "Hijo" + +#. module: mrp_tag +#: model:ir.model.fields,field_description:mrp_tag.field_mrp_tag__color +msgid "Color" +msgstr "Color" + +#. module: mrp_tag +#: model_terms:ir.actions.act_window,help:mrp_tag.mrp_tag_action +msgid "Create new tags for your manufacture order" +msgstr "Crear nuevas etiquetas para su orden de fabricación" + +#. module: mrp_tag +#: model:ir.model.fields,field_description:mrp_tag.field_mrp_tag__create_uid +msgid "Created by" +msgstr "Creado por" + +#. module: mrp_tag +#: model:ir.model.fields,field_description:mrp_tag.field_mrp_tag__create_date +msgid "Created on" +msgstr "Creado el" + +#. module: mrp_tag +#: model:ir.model.fields,field_description:mrp_tag.field_mrp_tag__display_name +msgid "Display Name" +msgstr "Mostrar Nombre" + +#. module: mrp_tag +#: model:ir.model.fields,field_description:mrp_tag.field_mrp_tag__id +msgid "ID" +msgstr "ID" + +#. module: mrp_tag +#: model:ir.model.fields,field_description:mrp_tag.field_mrp_tag__write_uid +msgid "Last Updated by" +msgstr "Última Actualización por" + +#. module: mrp_tag +#: model:ir.model.fields,field_description:mrp_tag.field_mrp_tag__write_date +msgid "Last Updated on" +msgstr "Última Actualización el" + +#. module: mrp_tag +#: model:ir.model,name:mrp_tag.model_mrp_tag +msgid "MRP Tag" +msgstr "Etiqueta MRP" + +#. module: mrp_tag +#: model:ir.model.fields,field_description:mrp_tag.field_mrp_tag__parent_id +msgid "Parent" +msgstr "Parental" + +#. module: mrp_tag +#: model:ir.model.fields,field_description:mrp_tag.field_mrp_tag__parent_path +msgid "Parent Path" +msgstr "Ruta Parental" + +#. module: mrp_tag +#: model:ir.model,name:mrp_tag.model_mrp_production +msgid "Production Order" +msgstr "Orden de Producción" + +#. module: mrp_tag +#: model_terms:ir.ui.view,arch_db:mrp_tag.view_mrp_production_filter +msgid "Tag" +msgstr "Etiqueta" + +#. module: mrp_tag +#: model:ir.model.fields,field_description:mrp_tag.field_mrp_tag__name +msgid "Tag Name" +msgstr "Nombre de Etiqueta" + +#. module: mrp_tag +#: model:ir.model.constraint,message:mrp_tag.constraint_mrp_tag_tag_name_uniq +msgid "Tag name already exists !" +msgstr "¡Este nombre de etiqueta ya existe !" + +#. module: mrp_tag +#: model:ir.actions.act_window,name:mrp_tag.mrp_tag_action +#: model:ir.model.fields,field_description:mrp_tag.field_mrp_production__tag_ids +#: model:ir.ui.menu,name:mrp_tag.menu_mrp_tag_config +#: model_terms:ir.ui.view,arch_db:mrp_tag.mrp_tag_view_form +msgid "Tags" +msgstr "Etiquetas" + +#. module: mrp_tag +#. odoo-python +#: code:addons/mrp_tag/models/mrp_tag.py:0 +#, python-format +msgid "Tags cannot be recursive." +msgstr "Las etiquetas no pueden ser recursivas." + +#~ msgid "Last Modified on" +#~ msgstr "Última Modificación el" diff --git a/mrp_tag/i18n/it.po b/mrp_tag/i18n/it.po new file mode 100644 index 00000000000..45951fb32f8 --- /dev/null +++ b/mrp_tag/i18n/it.po @@ -0,0 +1,118 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mrp_tag +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-09-05 09: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: mrp_tag +#: model:ir.model.fields,field_description:mrp_tag.field_mrp_tag__child_ids +msgid "Child" +msgstr "Figlio" + +#. module: mrp_tag +#: model:ir.model.fields,field_description:mrp_tag.field_mrp_tag__color +msgid "Color" +msgstr "Colore" + +#. module: mrp_tag +#: model_terms:ir.actions.act_window,help:mrp_tag.mrp_tag_action +msgid "Create new tags for your manufacture order" +msgstr "Crea nuove etichette per l'ordine di produzione" + +#. module: mrp_tag +#: model:ir.model.fields,field_description:mrp_tag.field_mrp_tag__create_uid +msgid "Created by" +msgstr "Creato da" + +#. module: mrp_tag +#: model:ir.model.fields,field_description:mrp_tag.field_mrp_tag__create_date +msgid "Created on" +msgstr "Creato il" + +#. module: mrp_tag +#: model:ir.model.fields,field_description:mrp_tag.field_mrp_tag__display_name +msgid "Display Name" +msgstr "Nome visualizzato" + +#. module: mrp_tag +#: model:ir.model.fields,field_description:mrp_tag.field_mrp_tag__id +msgid "ID" +msgstr "ID" + +#. module: mrp_tag +#: model:ir.model.fields,field_description:mrp_tag.field_mrp_tag__write_uid +msgid "Last Updated by" +msgstr "Ultimo aggiornamento di" + +#. module: mrp_tag +#: model:ir.model.fields,field_description:mrp_tag.field_mrp_tag__write_date +msgid "Last Updated on" +msgstr "Ultimo aggiornamento il" + +#. module: mrp_tag +#: model:ir.model,name:mrp_tag.model_mrp_tag +msgid "MRP Tag" +msgstr "Etichetta MRP" + +#. module: mrp_tag +#: model:ir.model.fields,field_description:mrp_tag.field_mrp_tag__parent_id +msgid "Parent" +msgstr "Padre" + +#. module: mrp_tag +#: model:ir.model.fields,field_description:mrp_tag.field_mrp_tag__parent_path +msgid "Parent Path" +msgstr "Percorso padre" + +#. module: mrp_tag +#: model:ir.model,name:mrp_tag.model_mrp_production +msgid "Production Order" +msgstr "Ordine di produzione" + +#. module: mrp_tag +#: model_terms:ir.ui.view,arch_db:mrp_tag.view_mrp_production_filter +msgid "Tag" +msgstr "Etichetta" + +#. module: mrp_tag +#: model:ir.model.fields,field_description:mrp_tag.field_mrp_tag__name +msgid "Tag Name" +msgstr "Nome etichetta" + +#. module: mrp_tag +#: model:ir.model.constraint,message:mrp_tag.constraint_mrp_tag_tag_name_uniq +msgid "Tag name already exists !" +msgstr "Il nome etichetta esiste già!" + +#. module: mrp_tag +#: model:ir.actions.act_window,name:mrp_tag.mrp_tag_action +#: model:ir.model.fields,field_description:mrp_tag.field_mrp_production__tag_ids +#: model:ir.ui.menu,name:mrp_tag.menu_mrp_tag_config +#: model_terms:ir.ui.view,arch_db:mrp_tag.mrp_tag_view_form +msgid "Tags" +msgstr "Etichette" + +#. module: mrp_tag +#. odoo-python +#: code:addons/mrp_tag/models/mrp_tag.py:0 +#, python-format +msgid "Tags cannot be recursive." +msgstr "Le etichette non possono essere ricorsive." + +#~ msgid "Last Modified on" +#~ msgstr "Ultima modifica il" + +#~ msgid "Tag Color" +#~ msgstr "Colore etichetta" diff --git a/mrp_tag/i18n/mrp_tag.pot b/mrp_tag/i18n/mrp_tag.pot new file mode 100644 index 00000000000..61e4052cc16 --- /dev/null +++ b/mrp_tag/i18n/mrp_tag.pot @@ -0,0 +1,109 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mrp_tag +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.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: mrp_tag +#: model:ir.model.fields,field_description:mrp_tag.field_mrp_tag__child_ids +msgid "Child" +msgstr "" + +#. module: mrp_tag +#: model:ir.model.fields,field_description:mrp_tag.field_mrp_tag__color +msgid "Color" +msgstr "" + +#. module: mrp_tag +#: model_terms:ir.actions.act_window,help:mrp_tag.mrp_tag_action +msgid "Create new tags for your manufacture order" +msgstr "" + +#. module: mrp_tag +#: model:ir.model.fields,field_description:mrp_tag.field_mrp_tag__create_uid +msgid "Created by" +msgstr "" + +#. module: mrp_tag +#: model:ir.model.fields,field_description:mrp_tag.field_mrp_tag__create_date +msgid "Created on" +msgstr "" + +#. module: mrp_tag +#: model:ir.model.fields,field_description:mrp_tag.field_mrp_tag__display_name +msgid "Display Name" +msgstr "" + +#. module: mrp_tag +#: model:ir.model.fields,field_description:mrp_tag.field_mrp_tag__id +msgid "ID" +msgstr "" + +#. module: mrp_tag +#: model:ir.model.fields,field_description:mrp_tag.field_mrp_tag__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: mrp_tag +#: model:ir.model.fields,field_description:mrp_tag.field_mrp_tag__write_date +msgid "Last Updated on" +msgstr "" + +#. module: mrp_tag +#: model:ir.model,name:mrp_tag.model_mrp_tag +msgid "MRP Tag" +msgstr "" + +#. module: mrp_tag +#: model:ir.model.fields,field_description:mrp_tag.field_mrp_tag__parent_id +msgid "Parent" +msgstr "" + +#. module: mrp_tag +#: model:ir.model.fields,field_description:mrp_tag.field_mrp_tag__parent_path +msgid "Parent Path" +msgstr "" + +#. module: mrp_tag +#: model:ir.model,name:mrp_tag.model_mrp_production +msgid "Production Order" +msgstr "" + +#. module: mrp_tag +#: model_terms:ir.ui.view,arch_db:mrp_tag.view_mrp_production_filter +msgid "Tag" +msgstr "" + +#. module: mrp_tag +#: model:ir.model.fields,field_description:mrp_tag.field_mrp_tag__name +msgid "Tag Name" +msgstr "" + +#. module: mrp_tag +#: model:ir.model.constraint,message:mrp_tag.constraint_mrp_tag_tag_name_uniq +msgid "Tag name already exists !" +msgstr "" + +#. module: mrp_tag +#: model:ir.actions.act_window,name:mrp_tag.mrp_tag_action +#: model:ir.model.fields,field_description:mrp_tag.field_mrp_production__tag_ids +#: model:ir.ui.menu,name:mrp_tag.menu_mrp_tag_config +#: model_terms:ir.ui.view,arch_db:mrp_tag.mrp_tag_view_form +msgid "Tags" +msgstr "" + +#. module: mrp_tag +#. odoo-python +#: code:addons/mrp_tag/models/mrp_tag.py:0 +#, python-format +msgid "Tags cannot be recursive." +msgstr "" diff --git a/mrp_tag/models/__init__.py b/mrp_tag/models/__init__.py new file mode 100644 index 00000000000..8eb5f37651f --- /dev/null +++ b/mrp_tag/models/__init__.py @@ -0,0 +1,2 @@ +from . import mrp_tag +from . import mrp_production diff --git a/mrp_tag/models/mrp_production.py b/mrp_tag/models/mrp_production.py new file mode 100644 index 00000000000..8d1e4dd4b5d --- /dev/null +++ b/mrp_tag/models/mrp_production.py @@ -0,0 +1,17 @@ +# Copyright 2022 ForgeFlow S.L. +# (http://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + + +class MrpProduction(models.Model): + _inherit = "mrp.production" + + tag_ids = fields.Many2many( + comodel_name="mrp.tag", + relation="mrp_production_tag_rel", + column1="mrp_production_id", + column2="tag_id", + string="Tags", + ) diff --git a/mrp_tag/models/mrp_tag.py b/mrp_tag/models/mrp_tag.py new file mode 100644 index 00000000000..f89a5b64bd2 --- /dev/null +++ b/mrp_tag/models/mrp_tag.py @@ -0,0 +1,49 @@ +# Copyright 2022 ForgeFlow S.L. +# (http://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from random import randint + +from odoo import _, api, fields, models +from odoo.exceptions import ValidationError + + +class MrpTag(models.Model): + _name = "mrp.tag" + _description = "MRP Tag" + _parent_store = True + + def _get_default_color(self): + return randint(1, 11) + + name = fields.Char("Tag Name", required=True, translate=True) + color = fields.Integer(default=lambda self: self._get_default_color()) + parent_id = fields.Many2one("mrp.tag", index=True, ondelete="cascade") + child_ids = fields.One2many("mrp.tag", "parent_id") + parent_path = fields.Char(index=True) + + _sql_constraints = [ + ("tag_name_uniq", "unique (name)", "Tag name already exists !"), + ] + + @api.depends("name", "parent_id") + def _compute_display_name(self): + for tag in self: + names = [] + current = tag + while current.name: + names.append(current.name) + current = current.parent_id + tag.display_name = " / ".join(reversed(names)) + + @api.model + def _search_display_name(self, operator, value): + domain = super()._search_display_name(operator, value) + if value: + return [("name", operator, value.split(" / ")[-1])] + list(domain or []) + return domain + + @api.constrains("parent_id") + def _check_parent_recursion(self): + if self._has_cycle("parent_id"): + raise ValidationError(_("Tags cannot be recursive.")) diff --git a/mrp_tag/pyproject.toml b/mrp_tag/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/mrp_tag/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/mrp_tag/readme/CONTRIBUTORS.md b/mrp_tag/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..7ace5427cbd --- /dev/null +++ b/mrp_tag/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- Jasmin Solanki \<\> +- Arturo Arribas \<\> +- Heliconia Solutions Pvt. Ltd. \<\> diff --git a/mrp_tag/readme/DESCRIPTION.md b/mrp_tag/readme/DESCRIPTION.md new file mode 100644 index 00000000000..c66d43dc8c6 --- /dev/null +++ b/mrp_tag/readme/DESCRIPTION.md @@ -0,0 +1 @@ +This module allows to add multiple tags to Manufacturing Orders diff --git a/mrp_tag/readme/USAGE.md b/mrp_tag/readme/USAGE.md new file mode 100644 index 00000000000..88caa0bcc3d --- /dev/null +++ b/mrp_tag/readme/USAGE.md @@ -0,0 +1 @@ +To use this module, you need to go to Manufacture Order and select tag. diff --git a/mrp_tag/security/ir.model.access.csv b/mrp_tag/security/ir.model.access.csv new file mode 100644 index 00000000000..7b52950a34f --- /dev/null +++ b/mrp_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_mrp_tag,mrp_tag,model_mrp_tag,base.group_user,1,0,0,0 +access_mrp_tag_manager,mrp_tag_manager,model_mrp_tag,mrp.group_mrp_manager,1,1,1,1 diff --git a/mrp_tag/static/description/icon.png b/mrp_tag/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/mrp_tag/static/description/icon.png differ diff --git a/mrp_tag/static/description/index.html b/mrp_tag/static/description/index.html new file mode 100644 index 00000000000..c38f9af373f --- /dev/null +++ b/mrp_tag/static/description/index.html @@ -0,0 +1,430 @@ + + + + + +MRP Tags + + + +
+

MRP Tags

+ + +

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

+

This module allows to add multiple tags to Manufacturing Orders

+

Table of contents

+ +
+

Usage

+

To use this module, you need to go to Manufacture Order and select tag.

+
+
+

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

+
    +
  • ForgeFlow
  • +
+
+
+

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

+

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

+
+
+
+ + diff --git a/mrp_tag/tests/__init__.py b/mrp_tag/tests/__init__.py new file mode 100644 index 00000000000..3d8a30a56ac --- /dev/null +++ b/mrp_tag/tests/__init__.py @@ -0,0 +1 @@ +from . import mrp_tag_test diff --git a/mrp_tag/tests/mrp_tag_test.py b/mrp_tag/tests/mrp_tag_test.py new file mode 100644 index 00000000000..9657d271087 --- /dev/null +++ b/mrp_tag/tests/mrp_tag_test.py @@ -0,0 +1,95 @@ +from odoo.exceptions import ValidationError +from odoo.tests import TransactionCase +from odoo.tools import mute_logger + + +class TestMrpTag(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + + def setUp(self): + super().setUp() + self.MrpTag = self.env["mrp.tag"] + + # Create test tags + self.tag_parent = self.MrpTag.create( + { + "name": "Production", + } + ) + + self.tag_child = self.MrpTag.create( + { + "name": "Assembly", + "parent_id": self.tag_parent.id, + } + ) + + self.tag_grandchild = self.MrpTag.create( + { + "name": "Electronics", + "parent_id": self.tag_child.id, + } + ) + + def test_compute_display_name(self): + """Test the computation of hierarchical display names""" + self.assertEqual(self.tag_parent.display_name, "Production") + self.assertEqual(self.tag_child.display_name, "Production / Assembly") + self.assertEqual( + self.tag_grandchild.display_name, "Production / Assembly / Electronics" + ) + + def test_search_display_name(self): + """Test searching tags by display name""" + # Test exact match + tags = self.MrpTag.search([("display_name", "=", "Production / Assembly")]) + self.assertEqual(len(tags), 1) + self.assertEqual(tags[0], self.tag_child) + + # Test partial match + tags = self.MrpTag.search([("display_name", "ilike", "Electronics")]) + self.assertEqual(len(tags), 1) + self.assertEqual(tags[0], self.tag_grandchild) + + # Test non-existent tag + tags = self.MrpTag.search([("display_name", "=", "Non-existent")]) + self.assertEqual(len(tags), 0) + + def test_recursive_constraint(self): + """Test prevention of recursive tag hierarchies""" + with self.assertRaises(ValidationError), mute_logger("odoo.models"): + # Try to create a recursive hierarchy + self.tag_parent.write({"parent_id": self.tag_grandchild.id}) + + def test_create_tag_without_parent(self): + """Test creation of tag without parent""" + tag = self.MrpTag.create({"name": "Standalone"}) + self.assertEqual(tag.display_name, "Standalone") + self.assertFalse(tag.parent_id) + + def test_update_parent(self): + """Test updating tag parent""" + new_parent = self.MrpTag.create({"name": "NewParent"}) + + self.tag_child.write({"parent_id": new_parent.id}) + + self.assertEqual(self.tag_child.display_name, "NewParent / Assembly") + self.assertEqual( + self.tag_grandchild.display_name, "NewParent / Assembly / Electronics" + ) + + def test_delete_parent(self): + """Test behavior when parent tag is deleted""" + self.tag_parent.unlink() + + # Refresh records from database + self.tag_child.invalidate_cache() + self.tag_grandchild.invalidate_cache() + + # Child tags should still exist but with updated display names + self.assertTrue(self.tag_child.exists()) + self.assertTrue(self.tag_grandchild.exists()) + self.assertEqual(self.tag_child.display_name, "Assembly") + self.assertEqual(self.tag_grandchild.display_name, "Assembly / Electronics") diff --git a/mrp_tag/views/mrp_production_view.xml b/mrp_tag/views/mrp_production_view.xml new file mode 100644 index 00000000000..3442cdea1eb --- /dev/null +++ b/mrp_tag/views/mrp_production_view.xml @@ -0,0 +1,54 @@ + + + + + + + mrp.production.form + mrp.production + + + + + + + + + + mrp.production.tree + mrp.production + + + + + + + + + + mrp.production.search + mrp.production + + + + + + + + diff --git a/mrp_tag/views/mrp_tag_view.xml b/mrp_tag/views/mrp_tag_view.xml new file mode 100644 index 00000000000..3fc45db0fd9 --- /dev/null +++ b/mrp_tag/views/mrp_tag_view.xml @@ -0,0 +1,61 @@ + + + + + + + mrp.tag.view.form + mrp.tag + +
+ +
+
+
+

+ +

+
+ + + + + + +
+
+
+
+ + + mrp.tag.view.tree + mrp.tag + + + + + + + + + + + Tags + mrp.tag + + +

+ Create new tags for your manufacture order +

+
+
+ + +