[Fix] account : fix buildbot warnings
[odoo/odoo.git] / addons / account / test / price_accuracy00.yml
1 -   |
2     Tax Scenario:
3     In order to check that the accounting entries and tax engine works
4     efficiently with all kind of price accuracies we run this test scenario.
5 -  
6     Given the price accuracy for the account module is configured with two
7     digits
8 -  
9     !record {model: decimal.precision, id: product.decimal_account}:
10       digits: 2
11 -  
12     And we have a tax defined
13 -  
14     !record {model: account.tax, id: tax196}:
15       name: Tax 19.6%
16       amount: &tax 0.196
17       account_collected_id: account.a_recv
18       account_paid_id: account.a_recv
19 -  
20     And we define an invoice with one invoice line with a tax of *tax
21 -  
22     !record {model: account.invoice, id: invoice1}: &invoice
23         name: Precision Test
24         type: out_invoice
25         partner_id: base.res_partner_2
26         address_invoice_id: base.res_partner_address_1
27         account_id: account.a_recv
28         date_invoice: !eval time.strftime('%Y-%m-%d')
29         invoice_line:
30             - product_id: product.product_product_pc1
31               quantity: &qty 11.11
32               account_id: account.a_sale
33               uos_id: product.product_uom_unit
34               price_unit: &price 12.34
35               name: test
36               invoice_line_tax_id:
37                   - tax196
38 -  
39     When I press on the CREATE button on the invoice to open it.
40 -  
41     !python {model: account.invoice}: |
42         self.action_move_create(cr, uid, [ref("invoice1")])  
43 -  
44     Then I should see an account entry linked to this invoice.
45 -  
46     !assert {model: account.invoice, id: invoice1}:
47       test:
48         - bool(move_id)
49 -  
50     # This is not working, find a way to do that in YAML, *qty is not
51     # interpreted because it's not a node.
52     And this account entry must have a credit equals to 163.97€ which is
53     equal to *qty x *price x (1 + *tax)
54 -  
55     !assert {model: account.invoice, id: invoice1}:
56         test:
57             - abs(sum(x.credit for x in move_id.line_id) - 163.97) < 0.000001
58 -  
59     And this account entry must have a credit equals to the debit
60 -  
61     !assert {model: account.invoice, id: invoice1}:
62         test:
63             - abs(sum(x.credit - x.debit for x in move_id.line_id)) < 0.000001
64 -  
65     Then, I change the precision of numbers to 3 digits.
66 -  
67     !record {model: decimal.precision, id: product.decimal_account}:
68       digits: 3
69 -  
70     And I create another invoice with the same content.
71 -  
72     !record {model: account.invoice, id: invoice2}:
73         *invoice
74 -  
75     When I press on the CREATE button on the invoice to open it.
76 -  
77     !python {model: account.invoice}: |
78         self.action_move_create(cr, uid, [ref("invoice2")])  
79 -    
80     Then this account entry must have a credit equals to the debit
81 -  
82     !assert {model: account.invoice, id: invoice2}:
83         test:
84             - abs(sum(x.credit - x.debit for x in move_id.line_id)) < 0.000001
85 -
86     And this account entry must have a credit equals to 163.968€ which is
87     equal to *qty x *price x (1 + *tax)
88 -  
89     !python {model: account.invoice}: |
90         xid = "invoice2"
91         invoice = self.browse(cr, uid, ref(xid))
92         sum_of_credits = sum(x.credit for x in invoice.move_id.line_id)
93         log("The sum of credits for %s is %f", xid, sum_of_credits)
94         expected_value = 163.968
95         assert (sum_of_credits - expected_value) < 0.000001, "Wrong sum of credits: %f <> %f" % (sum_of_credits, expected_value)
96