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:
@@ -4,8 +4,8 @@
|
|||||||
"category": "Manufacturing",
|
"category": "Manufacturing",
|
||||||
"author": "Ilyas, Ooops, Odoo Community Association (OCA)",
|
"author": "Ilyas, Ooops, Odoo Community Association (OCA)",
|
||||||
"summary": "Dynamic BOM component based on product attribute",
|
"summary": "Dynamic BOM component based on product attribute",
|
||||||
"depends": ["mrp_account"],
|
"depends": ["mrp_account", "web_domain_field"],
|
||||||
"license": "LGPL-3",
|
"license": "AGPL-3",
|
||||||
"website": "https://github.com/OCA/manufacture",
|
"website": "https://github.com/OCA/manufacture",
|
||||||
"data": [
|
"data": [
|
||||||
"views/mrp_bom_views.xml",
|
"views/mrp_bom_views.xml",
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from odoo import _, api, fields, models
|
from odoo import _, api, fields, models
|
||||||
@@ -20,6 +21,21 @@ class MrpBomLine(models.Model):
|
|||||||
match_on_attribute_ids = fields.Many2many(
|
match_on_attribute_ids = fields.Many2many(
|
||||||
"product.attribute", string="Match on Attributes", readonly=True
|
"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")
|
@api.onchange("component_template_id")
|
||||||
def _onchange_component_template_id(self):
|
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):
|
class MrpBom(models.Model):
|
||||||
_inherit = "mrp.bom"
|
_inherit = "mrp.bom"
|
||||||
|
|||||||
@@ -19,6 +19,13 @@
|
|||||||
position="after"
|
position="after"
|
||||||
>
|
>
|
||||||
<field name="component_template_id" />
|
<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>
|
||||||
<xpath
|
<xpath
|
||||||
expr="//field[@name='bom_line_ids']//field[@name='product_id']"
|
expr="//field[@name='bom_line_ids']//field[@name='product_id']"
|
||||||
|
|||||||
@@ -2,3 +2,4 @@
|
|||||||
|
|
||||||
account-analytic
|
account-analytic
|
||||||
stock-logistics-warehouse
|
stock-logistics-warehouse
|
||||||
|
web
|
||||||
|
|||||||
Reference in New Issue
Block a user