forked from OCA/sale-workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_module.py
More file actions
44 lines (41 loc) · 1.6 KB
/
test_module.py
File metadata and controls
44 lines (41 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from odoo.tests.common import Form, TransactionCase
class TestModule(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.partner = cls.env["res.partner"].create(
{"name": "Test Partner", "sale_discount": 10}
)
cls.product = cls.env.ref("product.product_product_4")
cls.pricelist = cls.env["product.pricelist"].create(
{
"name": "Test multi-currency",
"discount_policy": "without_discount",
"currency_id": cls.env.ref("base.USD").id,
"item_ids": [
(
0,
0,
{
"applied_on": "3_global",
"compute_price": "percentage",
"percent_price": 20,
},
),
],
}
)
setting_form = Form(cls.env["res.config.settings"])
setting_form.general_discount = "discount2"
setting_form.pricelist_discount = "discount1"
setting_form.group_discount_per_so_line = True
setting_form.save().set_values()
def test_action_result(self):
sale_form = Form(self.env["sale.order"])
sale_form.partner_id = self.partner
sale_form.pricelist_id = self.pricelist
with sale_form.order_line.new() as line:
line.product_id = self.product
sale = sale_form.save()
self.assertEqual(sale.order_line.discount2, 10)
self.assertEqual(sale.order_line.discount1, 20)