From 5669593a797b8fbee189f8ce41437b8c39d3dbca Mon Sep 17 00:00:00 2001 From: "Touati Djamel (otd)" Date: Mon, 27 Jun 2022 14:16:18 +0000 Subject: [PATCH] [FIX] sale_mrp: fix the `test_reset_avco_kit` The test is incorrect because a search is made on all product variants instead of getting only the previously-created product variants The SO action_cancel function returns a wizard that is not processed, so the so was never canceled. we should call the private function instead closes odoo/odoo#94742 X-original-commit: c4e6562e669881047802f25866f3c2c19bf2394a Signed-off-by: Adrien Widart Signed-off-by: Djamel Touati (otd) --- addons/sale_mrp/tests/test_sale_mrp_kit_bom.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/addons/sale_mrp/tests/test_sale_mrp_kit_bom.py b/addons/sale_mrp/tests/test_sale_mrp_kit_bom.py index 1ba879018aa..585fbe175d3 100644 --- a/addons/sale_mrp/tests/test_sale_mrp_kit_bom.py +++ b/addons/sale_mrp/tests/test_sale_mrp_kit_bom.py @@ -185,7 +185,7 @@ class TestSaleMrpKitBom(TransactionCase): aluminium_legs = self.env['product.attribute.value'].create( {'attribute_id': attributes.id, 'name': 'Aluminium'}) - product = self.env['product.product'].create({ + product_template = self.env['product.template'].create({ 'name': 'test product', 'categ_id': product_category.id, 'attribute_line_ids': [(0, 0, { @@ -193,9 +193,7 @@ class TestSaleMrpKitBom(TransactionCase): 'value_ids': [(6, 0, [steel_legs.id, aluminium_legs.id])] })] }) - product_variant_ids = product.product_variant_ids.search([('id', '!=', product.id)]) - product_variant_ids[0].categ_id.property_cost_method = 'average' - product_variant_ids[1].categ_id.property_cost_method = 'average' + product_variant_ids = product_template.product_variant_ids # BoM 1 with component_1 self.env['mrp.bom'].create({ 'product_id': product_variant_ids[0].id, @@ -225,7 +223,7 @@ class TestSaleMrpKitBom(TransactionCase): 'order_id': so.id, }) so.action_confirm() - so.action_cancel() + so._action_cancel() so.action_draft() with Form(so) as so_form: with so_form.order_line.edit(0) as order_line_change: