diff --git a/mrp_bom_attribute_match/README.rst b/mrp_bom_attribute_match/README.rst index c81644097..e3865fbeb 100644 --- a/mrp_bom_attribute_match/README.rst +++ b/mrp_bom_attribute_match/README.rst @@ -10,9 +10,9 @@ BOM Attribute Match .. |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-LGPL--3-blue.png - :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html - :alt: License: LGPL-3 +.. |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/14.0/mrp_bom_attribute_match :alt: OCA/manufacture diff --git a/mrp_bom_attribute_match/__manifest__.py b/mrp_bom_attribute_match/__manifest__.py index 6fa47b638..825505c65 100644 --- a/mrp_bom_attribute_match/__manifest__.py +++ b/mrp_bom_attribute_match/__manifest__.py @@ -1,11 +1,11 @@ { "name": "BOM Attribute Match", - "version": "14.0.1.0.1", + "version": "14.0.1.0.2", "category": "Manufacturing", "author": "Ilyas, Ooops, Odoo Community Association (OCA)", "summary": "Dynamic BOM component based on product attribute", - "depends": ["mrp_account"], - "license": "LGPL-3", + "depends": ["mrp_account", "web_domain_field"], + "license": "AGPL-3", "website": "https://github.com/OCA/manufacture", "data": [ "views/mrp_bom_views.xml", diff --git a/mrp_bom_attribute_match/i18n/hr.po b/mrp_bom_attribute_match/i18n/hr.po index a64adba07..6c49fa541 100644 --- a/mrp_bom_attribute_match/i18n/hr.po +++ b/mrp_bom_attribute_match/i18n/hr.po @@ -83,6 +83,11 @@ msgstr "Pričuvni proizvod" msgid "Product Template" msgstr "Predložak proizvoda" +#. module: mrp_bom_attribute_match +#: model:ir.model.fields,field_description:mrp_bom_attribute_match.field_mrp_bom_line__product_uom_id_domain +msgid "Product Uom Id Domain" +msgstr "" + #. module: mrp_bom_attribute_match #: model:ir.model,name:mrp_bom_attribute_match.model_mrp_production msgid "Production Order" @@ -117,7 +122,9 @@ msgstr "Tehničko polje za pohranu prethodne vrijednosti polja product_id" #: code:addons/mrp_bom_attribute_match/models/product.py:0 #, python-format msgid "" -"The attributes you're trying to remove is used in BoM as a match with Component (Product Template). To remove these attributes, first remove the BOM line with the matching component.\n" +"The attributes you're trying to remove is used in BoM as a match with " +"Component (Product Template). To remove these attributes, first remove the " +"BOM line with the matching component.\n" "Attributes: %s\n" "BoM: %s" msgstr "" diff --git a/mrp_bom_attribute_match/i18n/it.po b/mrp_bom_attribute_match/i18n/it.po index ad12dfab9..bc24993a9 100644 --- a/mrp_bom_attribute_match/i18n/it.po +++ b/mrp_bom_attribute_match/i18n/it.po @@ -68,6 +68,13 @@ msgstr "Ultima modifica il" msgid "Match on Attributes" msgstr "Corrispondenza su attributi" +#. module: mrp_bom_attribute_match +#: code:addons/mrp_bom_attribute_match/models/mrp_bom.py:0 +#, python-format +msgid "" +"No match on attribute has been detected for Component (Product Template) %s" +msgstr "" + #. module: mrp_bom_attribute_match #: model:ir.model.fields,field_description:mrp_bom_attribute_match.field_mrp_bom_line__product_backup_id msgid "Product Backup" @@ -78,6 +85,11 @@ msgstr "Backup componente" msgid "Product Template" msgstr "Modello Prodotto" +#. module: mrp_bom_attribute_match +#: model:ir.model.fields,field_description:mrp_bom_attribute_match.field_mrp_bom_line__product_uom_id_domain +msgid "Product Uom Id Domain" +msgstr "" + #. module: mrp_bom_attribute_match #: model:ir.model,name:mrp_bom_attribute_match.model_mrp_production msgid "Production Order" @@ -108,6 +120,17 @@ msgstr "" msgid "Technical field to store previous value of product_id" msgstr "Campo tecnico per preservare i valori di product_id" +#. module: mrp_bom_attribute_match +#: code:addons/mrp_bom_attribute_match/models/product.py:0 +#, python-format +msgid "" +"The attributes you're trying to remove is used in BoM as a match with " +"Component (Product Template). To remove these attributes, first remove the " +"BOM line with the matching component.\n" +"Attributes: %s\n" +"BoM: %s" +msgstr "" + #. module: mrp_bom_attribute_match #: code:addons/mrp_bom_attribute_match/models/product.py:0 #, python-format diff --git a/mrp_bom_attribute_match/i18n/mrp_bom_attribute_match.pot b/mrp_bom_attribute_match/i18n/mrp_bom_attribute_match.pot index 600a3c9e9..8278f03e9 100644 --- a/mrp_bom_attribute_match/i18n/mrp_bom_attribute_match.pot +++ b/mrp_bom_attribute_match/i18n/mrp_bom_attribute_match.pot @@ -79,6 +79,11 @@ msgstr "" msgid "Product Template" msgstr "" +#. module: mrp_bom_attribute_match +#: model:ir.model.fields,field_description:mrp_bom_attribute_match.field_mrp_bom_line__product_uom_id_domain +msgid "Product Uom Id Domain" +msgstr "" + #. module: mrp_bom_attribute_match #: model:ir.model,name:mrp_bom_attribute_match.model_mrp_production msgid "Production Order" diff --git a/mrp_bom_attribute_match/models/mrp_bom.py b/mrp_bom_attribute_match/models/mrp_bom.py index 0e6d5e7de..e3552e166 100644 --- a/mrp_bom_attribute_match/models/mrp_bom.py +++ b/mrp_bom_attribute_match/models/mrp_bom.py @@ -1,3 +1,4 @@ +import json import logging from odoo import _, api, fields, models @@ -20,6 +21,21 @@ class MrpBomLine(models.Model): match_on_attribute_ids = fields.Many2many( "product.attribute", string="Match on Attributes", readonly=True ) + product_uom_id_domain = fields.Char(compute="_compute_product_uom_id_domain") + + @api.depends("component_template_id", "product_id") + def _compute_product_uom_id_domain(self): + for r in self: + if r.component_template_id: + category_id = r.component_template_id.uom_id.category_id.id + if ( + r.product_uom_id.category_id.id + != r.component_template_id.uom_id.category_id.id + ): + r.product_uom_id = r.component_template_id.uom_id + else: + category_id = r.product_uom_category_id.id + r.product_uom_id_domain = json.dumps([("category_id", "=", category_id)]) @api.onchange("component_template_id") def _onchange_component_template_id(self): @@ -93,6 +109,9 @@ class MrpBomLine(models.Model): ) ) + def write(self, vals): + super(MrpBomLine, self).write(vals) + class MrpBom(models.Model): _inherit = "mrp.bom" diff --git a/mrp_bom_attribute_match/static/description/index.html b/mrp_bom_attribute_match/static/description/index.html index 44775fb6c..1c08184a0 100644 --- a/mrp_bom_attribute_match/static/description/index.html +++ b/mrp_bom_attribute_match/static/description/index.html @@ -367,7 +367,7 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -
+This module addresses the BoM case where the product to manufacture has one attribute with tens or hundreds of values (usually attribute “color”, eg: “Configurable Desk” can be produced in 900 different colors).
Creating a dynamic BoM currently requires adding one BoM line for each attribute value to match component variant with attribute value (eg: component “Desk board (Green)” to be applied to variant “Green”).
This has 3 downsides:
diff --git a/mrp_bom_attribute_match/views/mrp_bom_views.xml b/mrp_bom_attribute_match/views/mrp_bom_views.xml index 3b52384cd..90126ae7e 100644 --- a/mrp_bom_attribute_match/views/mrp_bom_views.xml +++ b/mrp_bom_attribute_match/views/mrp_bom_views.xml @@ -19,6 +19,13 @@ position="after" >