[MERGE] Merge with addons
[odoo/odoo.git] / addons / account / test / account_customer_invoice.yml
1 -
2   In order to test account invoice I create a new customer invoice
3 -
4   I will create bank detail with using manager access rights because account manager can only create bank details. 
5 -
6   !context
7     uid: 'res_users_account_manager'
8 -
9   !record {model: res.partner.bank, id: res_partner_bank_0}:
10     state: bank
11     company_id: base.main_company
12     partner_id: base.main_partner
13     acc_number: 123456789
14     footer: True
15     bank: base.res_bank_1
16     bank_name: Reserve
17 -
18   Test with that user which have rights to make Invoicing and payment and who is accountant. 
19 -
20   !context
21     uid: 'res_users_account_user'
22 -
23   I create a customer invoice
24 -
25   !record {model: account.invoice, id: account_invoice_customer0, view: invoice_form}:
26     payment_term: account.account_payment_term_advance
27     partner_bank_id: res_partner_bank_0
28     journal_id: account.sales_journal
29     partner_id: base.res_partner_3
30     reference_type: none
31     name: 'Test Customer Invoice'
32     invoice_line:
33       - product_id: product.product_product_5
34         quantity: 10.0
35 -
36   I manually assign tax on invoice
37 -
38   !python {model: account.invoice.tax}: |
39     amt = self.amount_change(cr, uid, [], 50.0, ref('base.EUR'), ref('base.main_company'), False)
40     base_amt = self.base_change(cr, uid, [], 9000.0, ref('base.EUR'), ref('base.main_company'), False)
41     invoice_tax_line = {
42         'name':  'Test Tax for Customer Invoice',
43         'manual': 1,
44         'base': base_amt['value']['base_amount'],
45         'amount': amt['value']['tax_amount'],
46         'account_id': ref('account.ova'),
47         'invoice_id': ref("account_invoice_customer0"),
48         }
49     tax = self.create(cr, uid, invoice_tax_line)
50     assert tax, "Tax has not been assigned correctly"
51
52 -
53   I check that Initially customer invoice is in the "Draft" state
54 -
55   !assert {model: account.invoice, id: account_invoice_customer0}:
56     - state == 'draft'
57 -
58   I change the state of invoice to "Proforma2" by clicking PRO-FORMA button
59 -
60   !workflow {model: account.invoice, action: invoice_proforma2, ref: account_invoice_customer0}
61 -
62   I check that the invoice state is now "Proforma2"
63 -
64   !assert {model: account.invoice, id: account_invoice_customer0}:
65     - state == 'proforma2'
66 -
67   I check that there is no move attached to the invoice
68 -
69   !python {model: account.invoice}: |
70     acc_id=self.browse(cr, uid, ref("account_invoice_customer0"))
71     assert (not acc_id.move_id), "Move falsely created at pro-forma"
72 -
73   I create invoice by clicking on Create button
74 -
75   !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_customer0}
76 -
77   I check that the invoice state is "Open"
78 -
79   !assert {model: account.invoice, id: account_invoice_customer0}:
80     - state == 'open'
81
82 -
83   I check that now there is a move attached to the invoice
84 -
85   !python {model: account.invoice}: |
86     acc_id=self.browse(cr, uid, ref("account_invoice_customer0"))
87     assert acc_id.move_id, "Move not created for open invoice"
88 -
89   I pay the Invoice
90 -
91   !python {model: account.invoice}: |
92     import time
93     pay = self.pay_and_reconcile(cr, uid, [ref('account_invoice_customer0')],
94         9050.0, ref('cash'), ref('account.period_10'),
95         ref('bank_journal'), ref('cash'),
96         ref('account.period_10'), ref('bank_journal'),
97         name='Payment for test customer invoice')
98     assert (pay == True), "Incorrect Payment"
99 -
100   I verify that invoice is now in Paid state
101 -
102   !python {model: account.invoice}: |
103     inv = self.browse(cr, uid, ref("account_invoice_customer0"))
104     assert (inv.state == 'paid'), "Invoice is not in Paid state"
105 -
106   I refund the invoice Using Refund Button
107 -
108   !record {model: account.invoice.refund, id: account_invoice_refund_0}:
109     description: Refund To China Export
110     period: account.period_5
111     filter_refund: refund
112 -
113   I clicked on refund button
114 -
115   !python {model: account.invoice.refund}: |
116     self.invoice_refund(cr, uid, [ref("account_invoice_refund_0")], {"lang": 'en_US', "tz": False, "active_model": "account.invoice", "active_ids": [ref("account.account_invoice_customer0")], "type": "out_invoice", "active_id": ref("account.account_invoice_customer0"), })
117 -
118   I checked that a new entry with state "Draft" created in account move line
119
120