From 97ab6269fc5fa60939ee3d45c94e0f6f68c28bf8 Mon Sep 17 00:00:00 2001 From: Hugo Date: Tue, 18 Apr 2023 17:14:53 +0200 Subject: [PATCH] [UPD]sale_cancel_reason change setUp to setUpClass --- .../tests/test_sale_cancel_reason.py | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/sale_cancel_reason/tests/test_sale_cancel_reason.py b/sale_cancel_reason/tests/test_sale_cancel_reason.py index a8639520839..684148d73b9 100644 --- a/sale_cancel_reason/tests/test_sale_cancel_reason.py +++ b/sale_cancel_reason/tests/test_sale_cancel_reason.py @@ -5,10 +5,27 @@ class TestSaleCancelReason(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + SaleOrder = cls.env["sale.order"] + CancelReason = cls.env["sale.order.cancel.reason"] + cls.reason = CancelReason.create({"name": "Canceled for tests"}) + cls.partner = cls.env.ref("base.res_partner_2") + cls.product = cls.env.ref("product.product_product_7") + cls.sale_order = SaleOrder.create( + { + "partner_id": cls.partner.id, + "order_line": [ + (0, 0, {"product_id": cls.product.id, "product_uom_qty": 8}) + ], + } + ) + def test_sale_order_cancel_reason(self): """ - - Cancel a sales order with the wizard asking for the reason - - Then the sale order should be canceled and the reason stored + - Cancel a sales order with the wizard asking for the reason. + - Then the sale order should be canceled and the reason stored. """ SaleOrderCancel = self.env["sale.order.cancel"] wizard = SaleOrderCancel.create( @@ -21,19 +38,3 @@ def test_sale_order_cancel_reason(self): self.sale_order.state, "cancel", "the sale order should be canceled" ) self.assertEqual(self.sale_order.cancel_reason_id.id, self.reason.id) - - def setUp(self): - super(TestSaleCancelReason, self).setUp() - SaleOrder = self.env["sale.order"] - CancelReason = self.env["sale.order.cancel.reason"] - self.reason = CancelReason.create({"name": "Canceled for tests"}) - self.partner = self.env.ref("base.res_partner_2") - self.product = self.env.ref("product.product_product_7") - self.sale_order = SaleOrder.create( - { - "partner_id": self.partner.id, - "order_line": [ - (0, 0, {"product_id": self.product.id, "product_uom_qty": 8}) - ], - } - )