mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[14.0][FIX] bom_attribute_match: BOM unit of measure should match uom of a component_template_id.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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 ""
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -367,7 +367,7 @@ ul.auto-toc {
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/manufacture/tree/14.0/mrp_bom_attribute_match"><img alt="OCA/manufacture" src="https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/manufacture-14-0/manufacture-14-0-mrp_bom_attribute_match"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/129/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/manufacture/tree/14.0/mrp_bom_attribute_match"><img alt="OCA/manufacture" src="https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/manufacture-14-0/manufacture-14-0-mrp_bom_attribute_match"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/129/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||
<p>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).</p>
|
||||
<p>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”).</p>
|
||||
<p>This has 3 downsides:</p>
|
||||
|
||||
@@ -19,6 +19,13 @@
|
||||
position="after"
|
||||
>
|
||||
<field name="component_template_id" />
|
||||
<field name="product_uom_id_domain" invisible="1" />
|
||||
</xpath>
|
||||
<xpath
|
||||
expr="//field[@name='bom_line_ids']//field[@name='product_uom_id']"
|
||||
position="attributes"
|
||||
>
|
||||
<attribute name="domain">product_uom_id_domain</attribute>
|
||||
</xpath>
|
||||
<xpath
|
||||
expr="//field[@name='bom_line_ids']//field[@name='product_id']"
|
||||
|
||||
Reference in New Issue
Block a user