[IMP] karma retag checks
[odoo/odoo.git] / addons / account / test / account_bank_statement.yml
1 -
2   In order to test Bank Statement feature of account I create a bank statement line and confirm it and check it's move created
3 -
4   I select the period and journal for the bank statement
5 -
6   !python {model: account.bank.statement}: |
7     import time
8     journal = self._default_journal_id(cr, uid, {'lang': u'en_US', 'tz': False, 'active_model': 'ir.ui.menu',
9       'journal_type': 'bank', 'period_id': time.strftime('%m'), 'active_ids': [ref('menu_bank_statement_tree')], 'active_id': ref('menu_bank_statement_tree')})
10     assert journal, 'Journal has not been selected'
11 -
12   I create a bank statement with Opening and Closing balance 0.
13 -
14   !record {model: account.bank.statement, id: account_bank_statement_0}:
15     balance_end_real: 0.0
16     balance_start: 0.0
17     date: !eval time.strftime('%Y-%m-%d')
18     journal_id: account.bank_journal
19 -
20   I create bank statement line
21 -
22   !python {model: account.bank.statement.line}: |
23     partner = self.onchange_partner_id(cr, uid, [], ref('base.res_partner_4'), context=None)
24     vals = {
25         'account_id': partner['value']['account_id'],
26         'amount': 1000.0,
27         'partner_id': ref('base.res_partner_4'),
28         'statement_id': ref('account_bank_statement_0'),
29         'name': 'EXT001'
30     }
31     vals.update(partner.get('value',{}))
32     line_id = self.create(cr, uid, vals)
33     assert line_id, "Account bank statement line has not been created"
34 -
35   I compute bank statement using Compute button
36 -
37   !python {model: account.bank.statement}: |
38     self.button_dummy(cr, uid, [ref("account_bank_statement_0")])
39
40 -
41   I modify the bank statement and set the Closing Balance.
42 -
43   !record {model: account.bank.statement, id: account_bank_statement_0}:
44     balance_end_real: 1000.0
45
46 -
47   I confirm the bank statement using Confirm button
48 -
49   !python {model: account.bank.statement}: |
50     self.button_confirm_bank(cr, uid, [ref("account_bank_statement_0")])
51 -
52   I check that bank statement state is now "Closed"
53 -
54   !assert {model: account.bank.statement, id: account_bank_statement_0}:
55     - state == 'confirm'
56
57 -
58   I check that move lines created for bank statement and move state is Posted
59 -
60   !python {model: account.bank.statement}: |
61     move_line_obj = self.pool.get('account.move.line')
62     bank_data = self.browse(cr, uid, ref("account_bank_statement_0"))
63     assert bank_data.move_line_ids, "Move lines not created for bank statement"
64     for line in bank_data.move_line_ids:
65       assert line.move_id.state == 'posted', "Move state is not posted"
66 -
67   Then I cancel Bank Statements and verifies that it raises a warning
68 -
69   !python {model: account.bank.statement}: |
70     from openerp.osv import osv
71     try:
72       self.button_cancel(cr, uid, [ref("account_bank_statement_0")])
73       assert False, "An exception should have been raised, the journal should not let us cancel moves!" 
74     except osv.except_osv:
75       # exception was raised as expected, as the journal does not allow cancelling moves
76       pass