Skip to content

Commit

Permalink
[UPD]sale_cancel_reason change setUp to setUpClass
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugo committed Apr 18, 2023
1 parent caa31db commit 97ab626
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions sale_cancel_reason/tests/test_sale_cancel_reason.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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})
],
}
)

0 comments on commit 97ab626

Please sign in to comment.