[FIX] mrp_bom_attribute_match: structure and cost report

This commit is contained in:
Ivàn Todorovich
2023-01-31 11:35:04 -03:00
committed by Ilyas
parent db8d61f804
commit 762f31bb21
2 changed files with 18 additions and 4 deletions

View File

@@ -2,7 +2,7 @@
# @author Iván Todorovich <ivan.todorovich@camptocamp.com>
# 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):
@@ -30,8 +30,7 @@ class ReportBomStructure(models.AbstractModel):
else:
line.product_id = line_product
if 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 = [Command.unlink(id) for id in to_ignore_line_ids]
components, total = super()._get_bom_lines(
bom, bom_quantity, product, line_id, level
)

View File

@@ -4,7 +4,7 @@ from odoo.tests import Form
from .common import TestMrpBomAttributeMatchBase
class TestMrpAttachmentMgmt(TestMrpBomAttributeMatchBase):
class TestMrpBomAttributeMatch(TestMrpBomAttributeMatchBase):
def test_bom_1(self):
mrp_bom_form = Form(self.env["mrp.bom"])
mrp_bom_form.product_tmpl_id = self.product_sword
@@ -154,3 +154,18 @@ class TestMrpAttachmentMgmt(TestMrpBomAttributeMatchBase):
)
with self.assertRaises(UserError):
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,
)