mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[IMP] mrp_bom_attribute_match: added demo data
This commit is contained in:
@@ -11,4 +11,5 @@
|
|||||||
"data": [
|
"data": [
|
||||||
"views/mrp_bom_views.xml",
|
"views/mrp_bom_views.xml",
|
||||||
],
|
],
|
||||||
|
"demo": ["demo/product_product_demo.xml"],
|
||||||
}
|
}
|
||||||
|
|||||||
197
mrp_bom_attribute_match/demo/product_product_demo.xml
Normal file
197
mrp_bom_attribute_match/demo/product_product_demo.xml
Normal file
@@ -0,0 +1,197 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<odoo noupdate="1">
|
||||||
|
|
||||||
|
<!-- PRODUCTS -->
|
||||||
|
|
||||||
|
<record id="bam_pp_top" model="product.template">
|
||||||
|
<field name="name">Top Level</field>
|
||||||
|
<field name="type">product</field>
|
||||||
|
<field name="sale_ok" eval="True" />
|
||||||
|
<field name="uom_id" ref="uom.product_uom_unit" />
|
||||||
|
<field name="uom_po_id" ref="uom.product_uom_unit" />
|
||||||
|
<field
|
||||||
|
name="route_ids"
|
||||||
|
eval="[(6, 0, [ref('mrp.route_warehouse0_manufacture')])]"
|
||||||
|
/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="bam_pp_sub_level" model="product.template">
|
||||||
|
<field name="name">Sub Level</field>
|
||||||
|
<field name="type">product</field>
|
||||||
|
<field name="sale_ok" eval="True" />
|
||||||
|
<field name="uom_id" ref="uom.product_uom_unit" />
|
||||||
|
<field name="uom_po_id" ref="uom.product_uom_unit" />
|
||||||
|
<field
|
||||||
|
name="route_ids"
|
||||||
|
eval="[(6, 0, [ref('mrp.route_warehouse0_manufacture')])]"
|
||||||
|
/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="bam_pp_sub_sub" model="product.template">
|
||||||
|
<field name="name">Sub Sub</field>
|
||||||
|
<field name="type">product</field>
|
||||||
|
<field name="sale_ok" eval="True" />
|
||||||
|
<field name="uom_id" ref="uom.product_uom_unit" />
|
||||||
|
<field name="uom_po_id" ref="uom.product_uom_unit" />
|
||||||
|
<field
|
||||||
|
name="route_ids"
|
||||||
|
eval="[(6, 0, [ref('mrp.route_warehouse0_manufacture')])]"
|
||||||
|
/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="bam_pp_sub_sub_2" model="product.template">
|
||||||
|
<field name="name">Sub Sub 2</field>
|
||||||
|
<field name="type">product</field>
|
||||||
|
<field name="sale_ok" eval="True" />
|
||||||
|
<field name="uom_id" ref="uom.product_uom_unit" />
|
||||||
|
<field name="uom_po_id" ref="uom.product_uom_unit" />
|
||||||
|
<field
|
||||||
|
name="route_ids"
|
||||||
|
eval="[(6, 0, [ref('mrp.route_warehouse0_manufacture')])]"
|
||||||
|
/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<!-- ATTRIBUTES -->
|
||||||
|
<record id="bam_attr_1" model="product.attribute">
|
||||||
|
<field name="name">attr1</field>
|
||||||
|
<field name="sequence">10</field>
|
||||||
|
</record>
|
||||||
|
<record id="bam_attr_1_office" model="product.attribute.value">
|
||||||
|
<field name="name">office</field>
|
||||||
|
<field name="attribute_id" ref="bam_attr_1" />
|
||||||
|
<field name="sequence">1</field>
|
||||||
|
</record>
|
||||||
|
<record id="bam_attr_1_gaming" model="product.attribute.value">
|
||||||
|
<field name="name">gaming</field>
|
||||||
|
<field name="attribute_id" ref="bam_attr_1" />
|
||||||
|
<field name="sequence">1</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="bam_attr_2" model="product.attribute">
|
||||||
|
<field name="name">attr2</field>
|
||||||
|
<field name="sequence">10</field>
|
||||||
|
</record>
|
||||||
|
<record id="bam_attr_2_v1" model="product.attribute.value">
|
||||||
|
<field name="name">v1</field>
|
||||||
|
<field name="attribute_id" ref="bam_attr_2" />
|
||||||
|
<field name="sequence">1</field>
|
||||||
|
</record>
|
||||||
|
<record id="bam_attr_2_v2" model="product.attribute.value">
|
||||||
|
<field name="name">v2</field>
|
||||||
|
<field name="attribute_id" ref="bam_attr_2" />
|
||||||
|
<field name="sequence">1</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<!-- PTALs -->
|
||||||
|
<record id="bam_ptal_1_1" model="product.template.attribute.line">
|
||||||
|
<field name="product_tmpl_id" ref="bam_pp_top" />
|
||||||
|
<field name="attribute_id" ref="bam_attr_1" />
|
||||||
|
<field
|
||||||
|
name="value_ids"
|
||||||
|
eval="[(6, 0, [ref('mrp_bom_attribute_match.bam_attr_1_office'), ref('mrp_bom_attribute_match.bam_attr_1_gaming')])]"
|
||||||
|
/>
|
||||||
|
</record>
|
||||||
|
<record id="bam_ptal_1_2" model="product.template.attribute.line">
|
||||||
|
<field name="product_tmpl_id" ref="bam_pp_top" />
|
||||||
|
<field name="attribute_id" ref="bam_attr_2" />
|
||||||
|
<field
|
||||||
|
name="value_ids"
|
||||||
|
eval="[(6, 0, [ref('mrp_bom_attribute_match.bam_attr_2_v1'), ref('mrp_bom_attribute_match.bam_attr_2_v2')])]"
|
||||||
|
/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="bam_ptal_2_1" model="product.template.attribute.line">
|
||||||
|
<field name="product_tmpl_id" ref="bam_pp_sub_level" />
|
||||||
|
<field name="attribute_id" ref="bam_attr_2" />
|
||||||
|
<field
|
||||||
|
name="value_ids"
|
||||||
|
eval="[(6, 0, [ref('mrp_bom_attribute_match.bam_attr_2_v1'), ref('mrp_bom_attribute_match.bam_attr_2_v2')])]"
|
||||||
|
/>
|
||||||
|
</record>
|
||||||
|
<record id="bam_ptal_2_2" model="product.template.attribute.line">
|
||||||
|
<field name="product_tmpl_id" ref="bam_pp_sub_level" />
|
||||||
|
<field name="attribute_id" ref="bam_attr_1" />
|
||||||
|
<field
|
||||||
|
name="value_ids"
|
||||||
|
eval="[(6, 0, [ref('mrp_bom_attribute_match.bam_attr_1_gaming'), ref('mrp_bom_attribute_match.bam_attr_1_office')])]"
|
||||||
|
/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="bam_ptal_3" model="product.template.attribute.line">
|
||||||
|
<field name="product_tmpl_id" ref="bam_pp_sub_sub" />
|
||||||
|
<field name="attribute_id" ref="bam_attr_1" />
|
||||||
|
<field
|
||||||
|
name="value_ids"
|
||||||
|
eval="[(6, 0, [ref('mrp_bom_attribute_match.bam_attr_1_office'), ref('mrp_bom_attribute_match.bam_attr_1_gaming')])]"
|
||||||
|
/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="bam_ptal_4" model="product.template.attribute.line">
|
||||||
|
<field name="product_tmpl_id" ref="bam_pp_sub_sub_2" />
|
||||||
|
<field name="attribute_id" ref="bam_attr_2" />
|
||||||
|
<field
|
||||||
|
name="value_ids"
|
||||||
|
eval="[(6, 0, [ref('mrp_bom_attribute_match.bam_attr_2_v1'), ref('mrp_bom_attribute_match.bam_attr_2_v2')])]"
|
||||||
|
/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<!-- PTAVs -->
|
||||||
|
<function model="ir.model.data" name="_update_xmlids">
|
||||||
|
<value
|
||||||
|
model="base"
|
||||||
|
eval="[{
|
||||||
|
'xml_id': 'mrp_bom_attribute_match.bam_pp_top_ptav_1',
|
||||||
|
'record': obj().env.ref('mrp_bom_attribute_match.bam_ptal_1_1').product_template_value_ids[0],
|
||||||
|
'noupdate': True,
|
||||||
|
},{
|
||||||
|
'xml_id': 'mrp_bom_attribute_match.bam_pp_top_ptav_2',
|
||||||
|
'record': obj().env.ref('mrp_bom_attribute_match.bam_ptal_1_2').product_template_value_ids[0],
|
||||||
|
'noupdate': True,
|
||||||
|
},{
|
||||||
|
'xml_id': 'mrp_bom_attribute_match.bam_pp_sub_level_ptav_1',
|
||||||
|
'record': obj().env.ref('mrp_bom_attribute_match.bam_ptal_2_1').product_template_value_ids[0],
|
||||||
|
'noupdate': True,
|
||||||
|
},{
|
||||||
|
'xml_id': 'mrp_bom_attribute_match.bam_pp_sub_level_ptav_2',
|
||||||
|
'record': obj().env.ref('mrp_bom_attribute_match.bam_ptal_2_2').product_template_value_ids[0],
|
||||||
|
'noupdate': True,
|
||||||
|
},{
|
||||||
|
'xml_id': 'mrp_bom_attribute_match.bam_pp_sub_sub_ptav_1',
|
||||||
|
'record': obj().env.ref('mrp_bom_attribute_match.bam_ptal_3').product_template_value_ids[0],
|
||||||
|
'noupdate': True,
|
||||||
|
},{
|
||||||
|
'xml_id': 'mrp_bom_attribute_match.bam_pp_sub_sub_2_ptav_1',
|
||||||
|
'record': obj().env.ref('mrp_bom_attribute_match.bam_ptal_4').product_template_value_ids[0],
|
||||||
|
'noupdate': True,
|
||||||
|
}]"
|
||||||
|
/>
|
||||||
|
</function>
|
||||||
|
|
||||||
|
<!-- BOMs -->
|
||||||
|
<record id="bam_bom_sub_level" model="mrp.bom">
|
||||||
|
<field name="product_tmpl_id" ref="bam_pp_sub_level" />
|
||||||
|
</record>
|
||||||
|
<record id="bam_bom_sub_level_line_1" model="mrp.bom.line">
|
||||||
|
<field name="component_template_id" ref="bam_pp_sub_sub" />
|
||||||
|
<field name="product_qty">1</field>
|
||||||
|
<field name="product_uom_id" ref="uom.product_uom_unit" />
|
||||||
|
<field name="bom_id" ref="bam_bom_sub_level" />
|
||||||
|
</record>
|
||||||
|
<record id="bam_bom_sub_level_line_2" model="mrp.bom.line">
|
||||||
|
<field name="component_template_id" ref="bam_pp_sub_sub_2" />
|
||||||
|
<field name="product_qty">1</field>
|
||||||
|
<field name="product_uom_id" ref="uom.product_uom_unit" />
|
||||||
|
<field name="bom_id" ref="bam_bom_sub_level" />
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="bam_bom_top_level" model="mrp.bom">
|
||||||
|
<field name="product_tmpl_id" ref="bam_pp_top" />
|
||||||
|
</record>
|
||||||
|
<record id="bam_bom_top_level_line_1" model="mrp.bom.line">
|
||||||
|
<field name="component_template_id" ref="bam_pp_sub_level" />
|
||||||
|
<field name="product_qty">1</field>
|
||||||
|
<field name="product_uom_id" ref="uom.product_uom_unit" />
|
||||||
|
<field name="bom_id" ref="bam_bom_top_level" />
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</odoo>
|
||||||
@@ -32,7 +32,9 @@ class ReportBomStructure(models.AbstractModel):
|
|||||||
if to_ignore_line_ids:
|
if to_ignore_line_ids:
|
||||||
for to_ignore_line_id in to_ignore_line_ids:
|
for to_ignore_line_id in to_ignore_line_ids:
|
||||||
bom.bom_line_ids = [(3, to_ignore_line_id, 0)]
|
bom.bom_line_ids = [(3, to_ignore_line_id, 0)]
|
||||||
product = bom._get_component_template_product(line, product, line.product_id)
|
product = bom._get_component_template_product(
|
||||||
|
line, product, line.product_id
|
||||||
|
)
|
||||||
components, total = super()._get_bom_lines(
|
components, total = super()._get_bom_lines(
|
||||||
bom, bom_quantity, product, line_id, level
|
bom, bom_quantity, product, line_id, level
|
||||||
)
|
)
|
||||||
@@ -74,6 +76,7 @@ class ReportBomStructure(models.AbstractModel):
|
|||||||
else:
|
else:
|
||||||
prod_qty = line.product_qty * factor / bom.product_qty
|
prod_qty = line.product_qty * factor / bom.product_qty
|
||||||
company = bom.company_id or self.env.company
|
company = bom.company_id or self.env.company
|
||||||
|
# Modification start
|
||||||
if line.component_template_id:
|
if line.component_template_id:
|
||||||
vals = product.product_template_attribute_value_ids.mapped(
|
vals = product.product_template_attribute_value_ids.mapped(
|
||||||
"product_attribute_value_id"
|
"product_attribute_value_id"
|
||||||
@@ -98,6 +101,7 @@ class ReportBomStructure(models.AbstractModel):
|
|||||||
price += company.currency_id.round(not_rounded_price)
|
price += company.currency_id.round(not_rounded_price)
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
|
# Modification end
|
||||||
else:
|
else:
|
||||||
not_rounded_price = (
|
not_rounded_price = (
|
||||||
line.product_id.uom_id._compute_price(
|
line.product_id.uom_id._compute_price(
|
||||||
|
|||||||
Reference in New Issue
Block a user