[FIX] account: correct test on closing fiscal year to fail with error message and...
[odoo/odoo.git] / addons / account / test / account_fiscalyear_close.yml
1 -
2   In order to test Generate Fiscalyear Opening Entries wizard of OpenERP I first create a fiscalyear to which the entries will move
3 -
4   !record {model: account.fiscalyear, id: account_fiscalyear_fiscalyear0}:
5     code: !eval "'FY%s'% (datetime.now().year+1)"
6     company_id: base.main_company
7     date_start: !eval "'%s-01-01' %(datetime.now().year-1)"
8     date_stop: !eval "'%s-12-31' %(datetime.now().year-1)"
9     name: !eval "'Fiscal Year %s' %(datetime.now().year-1)"
10 -
11   I generate periods for the new fiscalyear
12 -
13   !python {model: account.fiscalyear}: |
14     self.create_period(cr, uid, [ref("account_fiscalyear_fiscalyear0")])
15 -
16   I create a new account invoice in the created fiscalyear
17 -
18   !record {model: account.invoice, id: account_invoice_current1}:
19     partner_id: base.res_partner_2
20     date_invoice: !eval "'%s-01-02' %(datetime.now().year-1)"
21     invoice_line:
22       - partner_id: base.res_partner_2
23         quantity: 1.0
24         price_unit: 15.00
25         name: Bying stuff
26 -
27   I validate the invoice
28 -
29   !python {model: account.invoice}: |
30     import netsvc
31     wf_service = netsvc.LocalService("workflow")
32     wf_service.trg_validate(uid, 'account.invoice', ref('account.account_invoice_current1'), 'invoice_open', cr)
33 -
34   I made modification in journal so it can move entries
35 -
36   !record {model: account.journal, id: account.close_journal}:
37     name: End of Year
38     code: NEW
39     type: situation
40     analytic_journal_id: sit
41     default_debit_account_id: cash
42     default_credit_account_id: cash
43     company_id: base.main_company
44     centralisation: 1
45 -
46   I call the Generate Fiscalyear Opening Entries wizard
47 -
48   !record {model: account.fiscalyear.close, id: account_fiscalyear_close_0}:
49     fy2_id: account.data_fiscalyear
50     fy_id: account_fiscalyear_fiscalyear0
51     journal_id: account.close_journal
52     period_id: account.period_1
53     report_name: End of Fiscal Year Entry
54 -
55   I clicked on create Button
56 -
57   !python {model: account.fiscalyear.close}: |
58     self.data_save(cr, uid, [ref("account_fiscalyear_close_0")], {"lang": 'en_US',
59       "active_model": "ir.ui.menu", "active_ids": [ref("account.menu_wizard_fy_close")],
60       "tz": False, "active_id": ref("account.menu_wizard_fy_close"), })
61 -
62   I close the previous fiscalyear
63 -
64   !record {model: account.fiscalyear.close.state, id: account_fiscalyear_close_state_0}:
65     fy_id: account_fiscalyear_fiscalyear0
66 -
67   I clicked on Close States Button to close fiscalyear
68 -
69   !python {model: account.fiscalyear.close.state}: |
70     self.data_save(cr, uid, [ref("account_fiscalyear_close_state_0")], {"lang": 'en_US',
71       "active_model": "ir.ui.menu", "active_ids": [ref("account.menu_wizard_fy_close_state")],
72       "tz": False, "active_id": ref("account.menu_wizard_fy_close_state"), })
73 -
74   I check that the fiscalyear state is now "Done"
75 -
76   !assert {model: account.fiscalyear, id: account_fiscalyear_fiscalyear0, string: Fiscal Year is in Done state}:
77     - state == 'done'
78 -
79   I check that the past accounts are taken into account in partner credit
80 -
81   !assert {model: res.partner, id: base.res_partner_2, string: Total Receivable does not takes unreconciled moves of previous years}:
82     - credit == 15.0