[IMP] Account_voucher : YML test added for reports
[odoo/odoo.git] / addons / account_voucher / test / account_voucher.yml
1
2 -
3   In order to check account voucher module in OpenERP I create a customer voucher
4 -
5   !record {model: account.voucher, id: account_voucher_voucherforaxelor0}:
6     account_id: account.cash
7     company_id: base.main_company
8     currency_id: base.EUR
9     journal_id: account.bank_journal
10     name: Voucher for Axelor
11     narration: Basic Pc
12     line_ids:
13       - account_id: account.a_recv
14         amount: 1000.0
15         name: Voucher for Axelor
16         partner_id: base.res_partner_desertic_hispafuentes
17     period_id: account.period_6
18     reference_type: none
19
20 -
21   I check that Initially customer voucher is in the "Draft" state
22 -
23   !assert {model: account.voucher, id: account_voucher_voucherforaxelor0}:
24     - state == 'draft'
25 -
26   I compute the voucher to calculate the taxes by clicking Cpmpute button
27 -
28   !workflow {model: account.voucher, action: proforma_voucher, ref: account_voucher_voucherforaxelor0}
29 -
30   I check that the voucher state is now "proforma"
31 -
32   !assert {model: account.voucher, id: account_voucher_voucherforaxelor0}:
33     - state == 'proforma'
34 -
35   I create voucher by clicking on Create button
36 -
37   !workflow {model: account.voucher, action: proforma_voucher, ref: account_voucher_voucherforaxelor0}
38 -
39   I clicked on Validate Button
40 -
41   !assert {model: account.voucher, id: account_voucher_voucherforaxelor0}:
42     - state == 'posted'
43
44 -
45   I check that Moves get created for this voucher
46 -
47   !python {model: account.voucher}: |
48     acc_id=self.browse(cr, uid, ref("account_voucher_voucherforaxelor0"))
49     assert(acc_id.move_id)
50
51
52 -
53   Now I create a Vendor Voucher
54 -
55   !record {model: account.voucher, id: account_voucher_voucheraxelor0}:
56     account_id: account.cash
57     company_id: base.main_company
58     currency_id: base.EUR
59     journal_id: account.bank_journal
60     name: Voucher Axelor
61     narration: Basic PC
62     line_ids:
63       - account_id: account.cash
64         amount: 1000.0
65         name: Voucher Axelor
66     period_id: account.period_6
67     reference_type: none
68
69 -
70   I check that Initially vendor voucher is in the "Draft" state
71 -
72   !assert {model: account.voucher, id: account_voucher_voucheraxelor0}:
73     - state == 'draft'
74 -
75   I change the state of voucher to "proforma" by clicking PRO-FORMA button
76 -
77   !workflow {model: account.voucher, action: proforma_voucher, ref: account_voucher_voucheraxelor0}
78 -
79   I check that the voucher state is now "proforma"
80 -
81   !assert {model: account.voucher, id: account_voucher_voucheraxelor0}:
82     - state == 'proforma'
83 -
84   I create voucher by clicking on Create button
85 -
86   !workflow {model: account.voucher, action: proforma_voucher, ref: account_voucher_voucheraxelor0}
87 -
88   I check that the voucher state is "posted"
89 -
90   !assert {model: account.voucher, id: account_voucher_voucheraxelor0}:
91     - state == 'posted'
92 -
93   I check that moves get created for this voucher
94 -
95   !python {model: account.voucher}: |
96     acc_id=self.browse(cr, uid, ref("account_voucher_voucheraxelor0"))
97     assert(acc_id.move_id)
98
99 -
100   In order to test the PDF reports defined on a account_voucher, we will print account voucher amount Report
101 -
102   !python {model: account.voucher}: |
103     import netsvc, tools, os
104     (data, format) = netsvc.LocalService('report.voucher.cash_amount').create(cr, uid, [ref("account_voucher_voucheraxelor0")], {}, {})
105     if tools.config['test_report_directory']:
106         file(os.path.join(tools.config['test_report_directory'], 'account_voucher-amount.'+format), 'wb+').write(data)
107
108 -
109   In order to test the PDF reports defined on a account_voucher, we will print account voucher Report
110 -
111   !python {model: account.voucher}: |
112     import netsvc, tools, os
113     (data, format) = netsvc.LocalService('report.voucher.cash_receipt.drcr').create(cr, uid, [ref("account_voucher_voucheraxelor0")], {}, {})
114     if tools.config['test_report_directory']:
115         file(os.path.join(tools.config['test_report_directory'], 'account_voucher-report.'+format), 'wb+').write(data)