From e05442fe191aff4686d3adc4d7f689deef13e730 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Theys?= Date: Mon, 17 Jun 2019 09:42:16 +0000 Subject: [PATCH] [IMP] product, *: clean test and demo set up with attribute lines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * = account, mrp, purchase_stock, sale, sale_product_configurator, stock_account, website_sale It is always better to create the product template attribute lines before creating the variants. In a following commit, this will become mandatory. The variants that are created should always match the combination of attributes set on the template. Finally explicitly call `create_variant_ids` when possible instead of reassigning the attribute lines to implicitly call `create_variant_ids`. closes odoo/odoo#34122 Signed-off-by: Jérémy Kersten (jke) --- .../account/tests/test_product_id_change.py | 4 +- addons/mrp/tests/common.py | 2 +- addons/mrp/tests/test_bom.py | 11 ++-- addons/product/data/product_demo.xml | 54 +++++++++---------- addons/product/tests/common.py | 15 ++---- addons/product/tests/test_variants.py | 30 +++++++---- .../tests/test_onchange_product.py | 2 +- addons/sale/tests/test_onchange.py | 2 +- .../test_sale_product_configurator_ui.py | 20 +++---- ...o_saxon_valuation_reconciliation_common.py | 8 +-- addons/website_sale/data/demo.xml | 22 +++++--- 11 files changed, 87 insertions(+), 83 deletions(-) diff --git a/addons/account/tests/test_product_id_change.py b/addons/account/tests/test_product_id_change.py index c9ebaaebca3..88fce1d846b 100644 --- a/addons/account/tests/test_product_id_change.py +++ b/addons/account/tests/test_product_id_change.py @@ -43,8 +43,8 @@ class TestProductIdChange(AccountingTestCase): list_price='121', taxes_id=[(6, 0, [tax_include_sale.id])], supplier_taxes_id=[(6, 0, [tax_include_purchase.id])])) - product = self.product_model.create(dict(product_tmpl_id=product_tmpl.id, - standard_price='242')) + product = product_tmpl.product_variant_id + product.standard_price = '242' fp = self.fiscal_position_model.create(dict(name="fiscal position", sequence=1)) fp_tax_sale = self.fiscal_position_tax_model.create(dict(position_id=fp.id, tax_src_id=tax_include_sale.id, diff --git a/addons/mrp/tests/common.py b/addons/mrp/tests/common.py index 55e817e68f6..b9592d4720e 100644 --- a/addons/mrp/tests/common.py +++ b/addons/mrp/tests/common.py @@ -57,7 +57,7 @@ class TestMrpCommon(common2.TestStockCommon): user_group_mrp_byproducts = cls.env.ref('mrp.group_mrp_byproducts') # Update demo products - (cls.product_2 | cls.product_3 | cls.product_4 | cls.product_5 | cls.product_6 | cls.product_7 | cls.product_8).write({ + (cls.product_2 | cls.product_3 | cls.product_4 | cls.product_5 | cls.product_6 | cls.product_7_3 | cls.product_8).write({ 'type': 'product', }) diff --git a/addons/mrp/tests/test_bom.py b/addons/mrp/tests/test_bom.py index cacdf65189d..12cd389666f 100644 --- a/addons/mrp/tests/test_bom.py +++ b/addons/mrp/tests/test_bom.py @@ -4,7 +4,6 @@ from odoo import exceptions from odoo.tests import Form from odoo.addons.mrp.tests.common import TestMrpCommon -from odoo.tests import Form from odoo.tools import float_compare, float_round @@ -23,8 +22,8 @@ class TestBoM(TestMrpCommon): def test_variants(self): test_bom = self.env['mrp.bom'].create({ - 'product_id': self.product_7.id, - 'product_tmpl_id': self.product_7.product_tmpl_id.id, + 'product_id': self.product_7_3.id, + 'product_tmpl_id': self.product_7_template.id, 'product_uom_id': self.uom_unit.id, 'product_qty': 4.0, 'routing_id': self.routing_2.id, @@ -47,7 +46,7 @@ class TestBoM(TestMrpCommon): 'product_qty': 2, 'attribute_value_ids': [(4, self.prod_attr1_v2.id)], }) - boms, lines = test_bom.explode(self.product_7, 4) + boms, lines = test_bom.explode(self.product_7_3, 4) self.assertIn(test_bom, [b[0]for b in boms]) self.assertIn(test_bom_l1, [l[0] for l in lines]) self.assertNotIn(test_bom_l2, [l[0] for l in lines]) @@ -88,8 +87,8 @@ class TestBoM(TestMrpCommon): }) test_bom_2 = self.env['mrp.bom'].create({ - 'product_id': self.product_7.id, - 'product_tmpl_id': self.product_7.product_tmpl_id.id, + 'product_id': self.product_7_3.id, + 'product_tmpl_id': self.product_7_template.id, 'product_uom_id': self.uom_unit.id, 'product_qty': 4.0, 'routing_id': self.routing_2.id, diff --git a/addons/product/data/product_demo.xml b/addons/product/data/product_demo.xml index 1e7a7d3a37d..a46ab878d1a 100644 --- a/addons/product/data/product_demo.xml +++ b/addons/product/data/product_demo.xml @@ -183,6 +183,19 @@ 160x80cm, with large legs. + + + + + + + + + + + + + FURN_0096 500.0 @@ -216,21 +229,6 @@ - - - - - - - - - - - - - - - Corner Desk Right Sit @@ -311,35 +309,35 @@ - + Conference Chair 14 16.50 consu - 0.01 - E-COM12 - - - Conference Chair - E-COM13 - 0.01 - - - + - - + + E-COM12 + 0.01 + + + + + E-COM13 + 0.01 + + - - + Warranty - SERV_125889 20.0 9980 @@ -643,18 +641,26 @@ Warranty, issued to the purchaser of an article by its manufacturer, promising to repair or replace it if necessary within a specified period of time. - delivery + + - + - - - + + + SERV_125889 + + + + + SERV_125890 + +