mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[FIX] mrp_bom_attribute_match: structure and cost report
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
# @author Iván Todorovich <ivan.todorovich@camptocamp.com>
|
# @author Iván Todorovich <ivan.todorovich@camptocamp.com>
|
||||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
from odoo import models
|
from odoo import Command, models
|
||||||
|
|
||||||
|
|
||||||
class ReportBomStructure(models.AbstractModel):
|
class ReportBomStructure(models.AbstractModel):
|
||||||
@@ -30,8 +30,7 @@ class ReportBomStructure(models.AbstractModel):
|
|||||||
else:
|
else:
|
||||||
line.product_id = line_product
|
line.product_id = line_product
|
||||||
if to_ignore_line_ids:
|
if to_ignore_line_ids:
|
||||||
for to_ignore_line_id in to_ignore_line_ids:
|
bom.bom_line_ids = [Command.unlink(id) for id in to_ignore_line_ids]
|
||||||
bom.bom_line_ids = [(3, to_ignore_line_id, 0)]
|
|
||||||
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
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ from odoo.tests import Form
|
|||||||
from .common import TestMrpBomAttributeMatchBase
|
from .common import TestMrpBomAttributeMatchBase
|
||||||
|
|
||||||
|
|
||||||
class TestMrpAttachmentMgmt(TestMrpBomAttributeMatchBase):
|
class TestMrpBomAttributeMatch(TestMrpBomAttributeMatchBase):
|
||||||
def test_bom_1(self):
|
def test_bom_1(self):
|
||||||
mrp_bom_form = Form(self.env["mrp.bom"])
|
mrp_bom_form = Form(self.env["mrp.bom"])
|
||||||
mrp_bom_form.product_tmpl_id = self.product_sword
|
mrp_bom_form.product_tmpl_id = self.product_sword
|
||||||
@@ -154,3 +154,18 @@ class TestMrpAttachmentMgmt(TestMrpBomAttributeMatchBase):
|
|||||||
)
|
)
|
||||||
with self.assertRaises(UserError):
|
with self.assertRaises(UserError):
|
||||||
test_bom_3.explode(self.product_9, 1)
|
test_bom_3.explode(self.product_9, 1)
|
||||||
|
|
||||||
|
def test_mrp_report_bom_structure(self):
|
||||||
|
sword_cyan = self.product_sword.product_variant_ids[0]
|
||||||
|
BomStructureReport = self.env["report.mrp.report_bom_structure"]
|
||||||
|
res = BomStructureReport._get_report_data(self.bom_id.id)
|
||||||
|
self.assertTrue(res["is_variant_applied"])
|
||||||
|
self.assertEqual(res["lines"]["product"], sword_cyan)
|
||||||
|
self.assertEqual(
|
||||||
|
res["lines"]["components"][0]["line_id"],
|
||||||
|
self.bom_id.bom_line_ids.id,
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
res["lines"]["components"][0]["parent_id"],
|
||||||
|
self.bom_id.id,
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user