diff --git a/mrp_bom_tag/README.rst b/mrp_bom_tag/README.rst new file mode 100644 index 000000000..bb257c14e --- /dev/null +++ b/mrp_bom_tag/README.rst @@ -0,0 +1,86 @@ +=========== +MRP BoM Tag +=========== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:0bca0e075cd29504169d6c72f2f73a188e232c599003af33fc6feb99adee60de + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/16.0/mrp_bom_tag + :alt: OCA/manufacture +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/manufacture-16-0/manufacture-16-0-mrp_bom_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=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Add Tags in Bill Of Materials in order to find them easily with tag as keywords. + +.. figure:: https://raw.githubusercontent.com/OCA/manufacture/16.0/mrp_bom_tag/static/description/bom_with_tag.png + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +In Configuration / BoM Tags, user can configure its tags and parent's tags. + +.. figure:: https://raw.githubusercontent.com/OCA/manufacture/16.0/mrp_bom_tag/static/description/bom_tag_configuration.png + +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 +~~~~~~~ + +* GRAP +* + +Contributors +~~~~~~~~~~~~ + +* Quentin Dupont (quentin.dupont@grap.coop) + +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_bom_tag/__init__.py b/mrp_bom_tag/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/mrp_bom_tag/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/mrp_bom_tag/__manifest__.py b/mrp_bom_tag/__manifest__.py new file mode 100644 index 000000000..ae40e0da8 --- /dev/null +++ b/mrp_bom_tag/__manifest__.py @@ -0,0 +1,24 @@ +# Copyright (C) 2022 - Today: GRAP (http://www.grap.coop) +# @author: Quentin Dupont (quentin.dupont@grap.coop) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "MRP BoM Tag", + "summary": "Add tags on your BoM to find it easily", + "version": "16.0.1.0.0", + "category": "Manufacture", + "author": "GRAP, , Odoo Community Association (OCA)", + "website": "https://github.com/OCA/manufacture", + "license": "AGPL-3", + "depends": [ + "mrp", + ], + "demo": ["demo/mrp_bom_tag.xml"], + "data": [ + "security/ir_rule.xml", + "security/ir.model.access.csv", + "views/view_mrp_bom.xml", + "views/view_mrp_bom_tag.xml", + ], + "installable": True, +} diff --git a/mrp_bom_tag/demo/mrp_bom_tag.xml b/mrp_bom_tag/demo/mrp_bom_tag.xml new file mode 100644 index 000000000..748043b29 --- /dev/null +++ b/mrp_bom_tag/demo/mrp_bom_tag.xml @@ -0,0 +1,29 @@ + + + + + + Handmade + 2 + + + + Furniture + 9 + + + + + + Other + 1 + + + diff --git a/mrp_bom_tag/i18n/fr.po b/mrp_bom_tag/i18n/fr.po new file mode 100644 index 000000000..7ad8b7c95 --- /dev/null +++ b/mrp_bom_tag/i18n/fr.po @@ -0,0 +1,140 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mrp_bom_tag +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2022-10-14 14:06+0000\n" +"PO-Revision-Date: 2022-10-14 14:06+0000\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_bom_tag +#: model:ir.model,name:mrp_bom_tag.model_mrp_bom_tag +msgid "Bill Of Material Tag" +msgstr "Tag de nomenclature" + +#. module: mrp_bom_tag +#: model:ir.actions.act_window,name:mrp_bom_tag.action_bom_tag_2_mrp_bom +#: model:ir.model,name:mrp_bom_tag.model_mrp_bom +msgid "Bill of Material" +msgstr "Nomenclature" + +#. module: mrp_bom_tag +#: model_terms:ir.ui.view,arch_db:mrp_bom_tag.view_bom_tag_form +msgid "Bills of Material" +msgstr "Fiche technique" + +#. module: mrp_bom_tag +#: model:ir.model.fields,field_description:mrp_bom_tag.field_mrp_bom_tag__bom_qty +msgid "BoM Quantity" +msgstr "Quantité de fiches techniques" + +#. module: mrp_bom_tag +#: model:ir.actions.act_window,name:mrp_bom_tag.action_bom_tag +#: model:ir.ui.menu,name:mrp_bom_tag.menu_bom_tag +msgid "BoM Tags" +msgstr "Tags de fiches techniques" + +#. module: mrp_bom_tag +#: model:ir.model.fields,field_description:mrp_bom_tag.field_mrp_bom_tag__bom_ids +msgid "Bom" +msgstr "Fiche technique" + +#. module: mrp_bom_tag +#: model:ir.model.fields,field_description:mrp_bom_tag.field_mrp_bom_tag__child_id +msgid "Child Categories" +msgstr "Catégories Enfants" + +#. module: mrp_bom_tag +#: model:ir.model.fields,field_description:mrp_bom_tag.field_mrp_bom_tag__color +msgid "Color Index" +msgstr "Couleur" + +#. module: mrp_bom_tag +#: model:ir.model.fields,field_description:mrp_bom_tag.field_mrp_bom_tag__company_id +msgid "Company" +msgstr "Société" + +#. module: mrp_bom_tag +#: model:ir.model.fields,field_description:mrp_bom_tag.field_mrp_bom_tag__complete_name +msgid "Complete Name" +msgstr "Nom Complet" + +#. module: mrp_bom_tag +#: model:ir.model.fields,field_description:mrp_bom_tag.field_mrp_bom_tag__create_uid +msgid "Created by" +msgstr "Créé par" + +#. module: mrp_bom_tag +#: model:ir.model.fields,field_description:mrp_bom_tag.field_mrp_bom_tag__create_date +msgid "Created on" +msgstr "Créé le" + +#. module: mrp_bom_tag +#: model:ir.model.fields,field_description:mrp_bom_tag.field_mrp_bom_tag__display_name +msgid "Display Name" +msgstr "Nom affiché" + +#. module: mrp_bom_tag +#: model:ir.model.fields,field_description:mrp_bom_tag.field_mrp_bom_tag__id +msgid "ID" +msgstr "" + +#. module: mrp_bom_tag +#: model:ir.model.fields,field_description:mrp_bom_tag.field_mrp_bom_tag____last_update +msgid "Last Modified on" +msgstr "Dernière Modification le" + +#. module: mrp_bom_tag +#: model:ir.model.fields,field_description:mrp_bom_tag.field_mrp_bom_tag__write_uid +msgid "Last Updated by" +msgstr "Dernière mise à jour par" + +#. module: mrp_bom_tag +#: model:ir.model.fields,field_description:mrp_bom_tag.field_mrp_bom_tag__write_date +msgid "Last Updated on" +msgstr "Dernière mise à jour le" + +#. module: mrp_bom_tag +#: model:ir.model.fields,field_description:mrp_bom_tag.field_mrp_bom_tag__name +msgid "Name" +msgstr "Nom" + +#. module: mrp_bom_tag +#: model:ir.model.fields,help:mrp_bom_tag.field_mrp_bom_tag__bom_qty +msgid "Number of BoMs under this BoM tag (not considering children categories)" +msgstr "Nombre de Nomenclatures sous ce tag (ne compte pas les catégories enfants)" + +#. module: mrp_bom_tag +#: model:ir.model.fields,field_description:mrp_bom_tag.field_mrp_bom_tag__parent_id +msgid "Parent BoM Tag" +msgstr "Catégorie Tag parent" + +#. module: mrp_bom_tag +#: model:ir.model.fields,field_description:mrp_bom_tag.field_mrp_bom_tag__parent_path +msgid "Parent Path" +msgstr "Chemin parent" + +#. module: mrp_bom_tag +#: model:ir.model.fields,field_description:mrp_bom_tag.field_mrp_bom__bom_tag_ids +#: model_terms:ir.ui.view,arch_db:mrp_bom_tag.view_bom_tag_search +msgid "Tags" +msgstr "" + +#. module: mrp_bom_tag +#: model_terms:ir.ui.view,arch_db:mrp_bom_tag.view_mrp_bom_form +msgid "Tags 🎨" +msgstr "" + +#. module: mrp_bom_tag +#: code:addons/mrp_bom_tag/models/mrp_bom_tag.py:66 +#, python-format +msgid "You cannot create recursive bom tags." +msgstr "Vous ne pouvez pas créer de catégories de tag récursives." diff --git a/mrp_bom_tag/models/__init__.py b/mrp_bom_tag/models/__init__.py new file mode 100644 index 000000000..7ea9a2c10 --- /dev/null +++ b/mrp_bom_tag/models/__init__.py @@ -0,0 +1,2 @@ +from . import mrp_bom +from . import mrp_bom_tag diff --git a/mrp_bom_tag/models/mrp_bom.py b/mrp_bom_tag/models/mrp_bom.py new file mode 100644 index 000000000..b271621b5 --- /dev/null +++ b/mrp_bom_tag/models/mrp_bom.py @@ -0,0 +1,15 @@ +# Copyright (C) 2022 - Today: GRAP (http://www.grap.coop) +# @author: Quentin DUPONT (quentin.dupont@grap.coop) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + + +class MrpBom(models.Model): + _inherit = "mrp.bom" + + bom_tag_ids = fields.Many2many( + string="Tags", + comodel_name="mrp.bom.tag", + help="Choose or create your tags for your BoM and set its color.", + ) diff --git a/mrp_bom_tag/models/mrp_bom_tag.py b/mrp_bom_tag/models/mrp_bom_tag.py new file mode 100644 index 000000000..516676dde --- /dev/null +++ b/mrp_bom_tag/models/mrp_bom_tag.py @@ -0,0 +1,78 @@ +# Copyright (C) 2022 - Today: GRAP (http://www.grap.coop) +# @author: Quentin DUPONT (quentin.dupont@grap.coop) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from random import randint + +from odoo import api, fields, models + + +class MrpBomTag(models.Model): + _name = "mrp.bom.tag" + _description = "Bill Of Material Tag" + _parent_name = "parent_id" + _parent_store = True + _order = "complete_name" + + def _default_color(self): + return randint(1, 11) + + # Column Section + company_id = fields.Many2one( + comodel_name="res.company", + string="Company", + default=lambda s: s._default_company_id(), + ) + + name = fields.Char(required=True) + color = fields.Integer(default=lambda self: self._default_color()) + complete_name = fields.Char( + compute="_compute_complete_name", store=True, recursive=True + ) + + parent_id = fields.Many2one( + "mrp.bom.tag", "Parent BoM Tag", index=True, ondelete="cascade" + ) + parent_path = fields.Char(index=True, unaccent=False) + child_id = fields.One2many("mrp.bom.tag", "parent_id", "Child Categories") + + bom_ids = fields.Many2many( + comodel_name="mrp.bom", + ) + + bom_qty = fields.Integer( + "BoM Quantity", + compute="_compute_bom_qty", + help="Number of BoMs under this BoM tag (not considering children categories)", + ) + + @api.depends("name", "parent_id.complete_name") + def _compute_complete_name(self): + for bom_tag in self: + if bom_tag.parent_id: + bom_tag.complete_name = "%s / %s" % ( + bom_tag.parent_id.complete_name, + bom_tag.name, + ) + else: + bom_tag.complete_name = bom_tag.name + + @api.depends("bom_ids") + def _compute_bom_qty(self): + for bom_tag in self: + bom_tag.bom_qty = len(bom_tag.bom_ids) + + # Model Section + @api.model + def _default_company_id(self): + return self.env.company.id + + # Name Section + def name_get(self): + result = [] + for record in self: + if self.env.context.get("display_complete_name", False): + result.append((record.id, record.complete_name)) + else: + result.append((record.id, record.name)) + return result diff --git a/mrp_bom_tag/readme/CONFIGURE.rst b/mrp_bom_tag/readme/CONFIGURE.rst new file mode 100644 index 000000000..bb8414ee7 --- /dev/null +++ b/mrp_bom_tag/readme/CONFIGURE.rst @@ -0,0 +1,3 @@ +In Configuration / BoM Tags, user can configure its tags and parent's tags. + +.. figure:: ../static/description/bom_tag_configuration.png diff --git a/mrp_bom_tag/readme/CONTRIBUTORS.rst b/mrp_bom_tag/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..9ed470628 --- /dev/null +++ b/mrp_bom_tag/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Quentin Dupont (quentin.dupont@grap.coop) diff --git a/mrp_bom_tag/readme/DESCRIPTION.rst b/mrp_bom_tag/readme/DESCRIPTION.rst new file mode 100644 index 000000000..f91456e29 --- /dev/null +++ b/mrp_bom_tag/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +Add Tags in Bill Of Materials in order to find them easily with tag as keywords. + +.. figure:: ../static/description/bom_with_tag.png diff --git a/mrp_bom_tag/security/ir.model.access.csv b/mrp_bom_tag/security/ir.model.access.csv new file mode 100644 index 000000000..7c3ff2635 --- /dev/null +++ b/mrp_bom_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_bom_tag,Bill Of Material Tag All,model_mrp_bom_tag,base.group_user,1,0,0,0 +access_mrp_bom_tag_manager,Bill Of Material Tag Manager,model_mrp_bom_tag,mrp.group_mrp_manager,1,1,1,1 diff --git a/mrp_bom_tag/security/ir_rule.xml b/mrp_bom_tag/security/ir_rule.xml new file mode 100644 index 000000000..da1c7f1ca --- /dev/null +++ b/mrp_bom_tag/security/ir_rule.xml @@ -0,0 +1,23 @@ + + + + + + Bill Of Material Tag Rule + + + + [ + '|', + ('company_id','=',False), + ('company_id', 'in', company_ids) + ] + + + + + diff --git a/mrp_bom_tag/static/description/bom_tag_configuration.png b/mrp_bom_tag/static/description/bom_tag_configuration.png new file mode 100644 index 000000000..284c946de Binary files /dev/null and b/mrp_bom_tag/static/description/bom_tag_configuration.png differ diff --git a/mrp_bom_tag/static/description/bom_with_tag.png b/mrp_bom_tag/static/description/bom_with_tag.png new file mode 100644 index 000000000..dcd718b0f Binary files /dev/null and b/mrp_bom_tag/static/description/bom_with_tag.png differ diff --git a/mrp_bom_tag/static/description/index.html b/mrp_bom_tag/static/description/index.html new file mode 100644 index 000000000..22aab23e8 --- /dev/null +++ b/mrp_bom_tag/static/description/index.html @@ -0,0 +1,433 @@ + + + + + + +MRP BoM Tag + + + +
+

MRP BoM Tag

+ + +

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

+

Add Tags in Bill Of Materials in order to find them easily with tag as keywords.

+
+https://raw.githubusercontent.com/OCA/manufacture/16.0/mrp_bom_tag/static/description/bom_with_tag.png +
+

Table of contents

+ +
+

Configuration

+

In Configuration / BoM Tags, user can configure its tags and parent’s tags.

+
+https://raw.githubusercontent.com/OCA/manufacture/16.0/mrp_bom_tag/static/description/bom_tag_configuration.png +
+
+
+

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

+
    +
  • GRAP
  • +
  • +
+
+
+

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_bom_tag/tests/__init__.py b/mrp_bom_tag/tests/__init__.py new file mode 100644 index 000000000..7762673af --- /dev/null +++ b/mrp_bom_tag/tests/__init__.py @@ -0,0 +1 @@ +from . import test_bom_tag diff --git a/mrp_bom_tag/tests/test_bom_tag.py b/mrp_bom_tag/tests/test_bom_tag.py new file mode 100644 index 000000000..8d50f32c3 --- /dev/null +++ b/mrp_bom_tag/tests/test_bom_tag.py @@ -0,0 +1,39 @@ +# Copyright (C) 2022 - Today: GRAP (http://www.grap.coop) +# @author: Quentin DUPONT (quentin.dupont@grap.coop) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo.tests.common import TransactionCase + + +class TestBomTag(TransactionCase): + def setUp(self): + super(TestBomTag, self).setUp() + self.bomtag = self.env.ref("mrp_bom_tag.demo_bom_tag") + self.bomtag2 = self.env.ref("mrp_bom_tag.demo_bom_tag_2") + self.bomtagparent = self.env.ref("mrp_bom_tag.demo_bom_tag_parent") + self.bom_desk = self.env.ref("mrp.mrp_bom_manufacture") + + def test_01_bom_qty(self): + self.assertEqual( + self.bomtag2.bom_qty, + 0, + ) + self.bom_desk.write( + { + "bom_tag_ids": [ + (6, 0, [self.bomtag2.id]), + ] + } + ) + self.assertEqual( + self.bomtag2.bom_qty, + 1, + ) + + def test_02_name_get(self): + name_get_simple = self.bomtag.name_get() + name_get_complete = self.bomtag.with_context( + display_complete_name=True + ).name_get() + self.assertEqual(name_get_simple[0][1], "Furniture") + self.assertEqual(name_get_complete[0][1], "Handmade / Furniture") diff --git a/mrp_bom_tag/views/view_mrp_bom.xml b/mrp_bom_tag/views/view_mrp_bom.xml new file mode 100644 index 000000000..ccf59b122 --- /dev/null +++ b/mrp_bom_tag/views/view_mrp_bom.xml @@ -0,0 +1,60 @@ + + + + + + + + + + mrp.bom + + + + + + + + + + + + + + mrp.bom + + + + + + + + + + + + + + mrp.bom + + + + + + + + + diff --git a/mrp_bom_tag/views/view_mrp_bom_tag.xml b/mrp_bom_tag/views/view_mrp_bom_tag.xml new file mode 100644 index 000000000..065886d0c --- /dev/null +++ b/mrp_bom_tag/views/view_mrp_bom_tag.xml @@ -0,0 +1,98 @@ + + + + + + Bill of Material + mrp.bom + tree,form + [('bom_tag_ids', '=', active_id)] + + + + mrp.bom.tag + +
+ +
+ +
+
+
+
+

+ +

+
+ + + + + + + +
+
+
+
+ + + mrp.bom.tag + + + + + + + + + + + + + BoM Tags + ir.actions.act_window + mrp.bom.tag + tree,form + + + + + + + + + + mrp.bom.tag + + + + + + + +
diff --git a/setup/mrp_bom_tag/odoo/addons/mrp_bom_tag b/setup/mrp_bom_tag/odoo/addons/mrp_bom_tag new file mode 120000 index 000000000..3408aa013 --- /dev/null +++ b/setup/mrp_bom_tag/odoo/addons/mrp_bom_tag @@ -0,0 +1 @@ +../../../../mrp_bom_tag \ No newline at end of file diff --git a/setup/mrp_bom_tag/setup.py b/setup/mrp_bom_tag/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/mrp_bom_tag/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)