Skip to content

Commit

Permalink
[IMP]sale_commission_product_criteria: reorder test functions
Browse files Browse the repository at this point in the history
  • Loading branch information
PicchiSeba committed Oct 15, 2024
1 parent 2cf22f0 commit 67c97d2
Showing 1 changed file with 34 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,40 @@ def setUpClass(cls):
"sale_commission_product_criteria.demo_commission_rules_item_4"
)

def _create_sale_order(self, product, partner):
return self.sale_order_model.create(
{
"partner_id": partner.id,
"order_line": [
(
0,
0,
{
"name": product.name,
"product_id": product.id,
"product_uom_qty": 1.0,
"product_uom": product.uom_id.id,
"price_unit": 1000,
},
)
],
}
)

def _invoice_sale_order(self, sale_order, date=None):
old_invoices = sale_order.invoice_ids
wizard = self.advance_inv_model.create({"advance_payment_method": "delivered"})
wizard.with_context(
{
"active_model": "sale.order",
"active_ids": [sale_order.id],
"active_id": sale_order.id,
}
).create_invoices()
invoice = sale_order.invoice_ids - old_invoices
invoice.flush()
return invoice

def test_sale_commission_product_criteria_items(self):
# items names
self.com_item_1._compute_commission_item_name_value()
Expand Down Expand Up @@ -165,40 +199,6 @@ def test_sale_commission_product_criteria_items(self):
with self.assertRaises(ValidationError):
self.com_item_4._onchange_product_tmpl_id()

def _create_sale_order(self, product, partner):
return self.sale_order_model.create(
{
"partner_id": partner.id,
"order_line": [
(
0,
0,
{
"name": product.name,
"product_id": product.id,
"product_uom_qty": 1.0,
"product_uom": product.uom_id.id,
"price_unit": 1000,
},
)
],
}
)

def _invoice_sale_order(self, sale_order, date=None):
old_invoices = sale_order.invoice_ids
wizard = self.advance_inv_model.create({"advance_payment_method": "delivered"})
wizard.with_context(
{
"active_model": "sale.order",
"active_ids": [sale_order.id],
"active_id": sale_order.id,
}
).create_invoices()
invoice = sale_order.invoice_ids - old_invoices
invoice.flush()
return invoice

def test_on_create_check(self):
with Form(self.commission_model) as f:
f.name = "New commission type"
Expand Down

0 comments on commit 67c97d2

Please sign in to comment.