Skip to content

Commit 33ae3a0

Browse files
ivantodorovichmymage
authored andcommitted
[IMP] mrp_bom_attribute_match: increase test strenght: add another component to bom
1 parent 18034a3 commit 33ae3a0

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

mrp_bom_attribute_match/tests/common.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ def setUpClass(cls):
5656
"route_ids": [Command.link(cls.route_manufacture.id)],
5757
}
5858
)
59+
cls.p4 = cls.env["product.template"].create(
60+
{
61+
"name": "P4",
62+
"type": "product",
63+
"route_ids": [Command.link(cls.route_manufacture.id)],
64+
}
65+
)
5966
cls.product_9 = cls.env["product.product"].create(
6067
{
6168
"name": "Paper",
@@ -97,6 +104,10 @@ def setUpClass(cls):
97104
component_template_id=cls.product_plastic.id,
98105
product_qty=1,
99106
),
107+
dict(
108+
product_id=cls.product_9,
109+
product_qty=1,
110+
),
100111
],
101112
)
102113
cls.fin_bom_id = cls._create_bom(
@@ -139,7 +150,7 @@ def setUpClass(cls):
139150
cls.p3,
140151
[
141152
dict(
142-
product_id=cls.p1.product_variant_ids[0],
153+
product_id=cls.p4.product_variant_ids[0],
143154
product_qty=1,
144155
),
145156
],

mrp_bom_attribute_match/tests/test_mrp_bom_attribute_match.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,18 @@ def test_bom_2(self):
6767
plastic_smells_like_orchid.unlink()
6868

6969
def test_manufacturing_order_1(self):
70+
sword_cyan = self.product_sword.product_variant_ids[0]
71+
plastic_cyan = self.product_plastic.product_variant_ids[0]
7072
mo_form = Form(self.env["mrp.production"])
71-
mo_form.product_id = self.product_sword.product_variant_ids.filtered(
72-
lambda x: x.name == "Plastic Sword"
73-
)[0]
73+
mo_form.product_id = sword_cyan
7474
mo_form.bom_id = self.bom_id
7575
mo_form.product_qty = 1
7676
self.mo_sword = mo_form.save()
7777
self.mo_sword.action_confirm()
7878
# Assert correct component variant was selected automatically
7979
self.assertEqual(
80-
self.mo_sword.move_raw_ids.product_id.display_name,
81-
"Plastic Component (Cyan)",
80+
self.mo_sword.move_raw_ids.product_id,
81+
plastic_cyan + self.product_9,
8282
)
8383

8484
def test_manufacturing_order_2(self):
@@ -181,7 +181,11 @@ def test_mrp_report_bom_structure(self):
181181
self.assertEqual(res["lines"]["product"], sword_cyan)
182182
self.assertEqual(
183183
res["lines"]["components"][0]["line_id"],
184-
self.bom_id.bom_line_ids.id,
184+
self.bom_id.bom_line_ids[0].id,
185+
)
186+
self.assertEqual(
187+
res["lines"]["components"][1]["line_id"],
188+
self.bom_id.bom_line_ids[1].id,
185189
)
186190
self.assertEqual(
187191
res["lines"]["components"][0]["parent_id"],

0 commit comments

Comments
 (0)