From dcbc5efd0c96507009f33b0458a59a8f3f668cbb Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Thu, 24 Oct 2024 16:10:07 +0200 Subject: [PATCH 1/2] product_configurator: imp test setup w/ _configure_product_nxt_step Accept defaults for the wizard. --- product_configurator/tests/common.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/product_configurator/tests/common.py b/product_configurator/tests/common.py index d4adb4e44..663a24084 100644 --- a/product_configurator/tests/common.py +++ b/product_configurator/tests/common.py @@ -58,12 +58,12 @@ def setUpClass(cls): ) @classmethod - def _configure_product_nxt_step(cls): - product_config_wizard = cls.ProductConfWizard.create( - { - "product_tmpl_id": cls.config_product.id, - } - ) + def _configure_product_nxt_step(cls, **defaults): + vals = { + "product_tmpl_id": cls.config_product.id, + } + vals.update(defaults) + product_config_wizard = cls.ProductConfWizard.create(vals) product_config_wizard.action_next_step() product_config_wizard.write( { From 87018098c04958e76e7bbb7ed82df507cc3125fd Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Thu, 24 Oct 2024 16:16:03 +0200 Subject: [PATCH 2/2] product_configurator_sale: restore test_sale Was left disabled a long time ago --- product_configurator_sale/tests/__init__.py | 2 +- product_configurator_sale/tests/test_sale.py | 41 ++++++++++---------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/product_configurator_sale/tests/__init__.py b/product_configurator_sale/tests/__init__.py index be224966f..ae8e2f8a7 100644 --- a/product_configurator_sale/tests/__init__.py +++ b/product_configurator_sale/tests/__init__.py @@ -1,4 +1,4 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -# from . import test_sale +from . import test_sale from . import test_sale_order_line diff --git a/product_configurator_sale/tests/test_sale.py b/product_configurator_sale/tests/test_sale.py index 92b7a992a..53dc00ac5 100644 --- a/product_configurator_sale/tests/test_sale.py +++ b/product_configurator_sale/tests/test_sale.py @@ -1,44 +1,43 @@ -from odoo.addons.product_configurator.tests import ( - test_product_configurator_test_cases as TC, -) +from odoo.addons.product_configurator.tests.common import ProductConfiguratorTestCases -class SaleOrder(TC.ProductConfiguratorTestCases): - def setUp(self): - super(SaleOrder, self).setUp() - self.SaleOrderId = self.env["sale.order"] - self.productPricelist = self.env["product.pricelist"] - self.resPartner = self.env.ref("product_configurator_sale.partenr_sale_1") - self.currency_id = self.env.ref("base.USD") - self.ProductConfWizard = self.env["product.configurator.sale"] +class SaleOrder(ProductConfiguratorTestCases): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.SaleOrder = cls.env["sale.order"] + cls.productPricelist = cls.env["product.pricelist"] + cls.partner = cls.env.ref("product_configurator_sale.partenr_sale_1") + cls.currency = cls.env.ref("base.USD") + cls.ProductConfWizard = cls.env["product.configurator.sale"] def test_00_reconfigure_product(self): pricelist_id = self.productPricelist.create( { "name": "Test Pricelist", - "currency_id": self.currency_id.id, + "currency_id": self.currency.id, } ) - sale_order_id = self.SaleOrderId.create( + sale_order = self.SaleOrder.create( { - "partner_id": self.resPartner.id, - "partner_invoice_id": self.resPartner.id, - "partner_shipping_id": self.resPartner.id, + "partner_id": self.partner.id, + "partner_invoice_id": self.partner.id, + "partner_shipping_id": self.partner.id, "pricelist_id": pricelist_id.id, } ) context = dict( - default_order_id=sale_order_id.id, + default_order_id=sale_order.id, wizard_model="product.configurator.sale", ) self.ProductConfWizard = self.env["product.configurator.sale"].with_context( **context ) - sale_order_id.action_config_start() - self._configure_product_nxt_step() - sale_order_id.order_line.reconfigure_product() - product_tmpl = sale_order_id.order_line.product_id.product_tmpl_id + sale_order.action_config_start() + self._configure_product_nxt_step(order_id=sale_order.id) + sale_order.order_line.reconfigure_product() + product_tmpl = sale_order.order_line.product_id.product_tmpl_id self.assertEqual( product_tmpl.id, self.config_product.id,