[TEST]
[odoo/odoo.git] / addons / account / test / account_validate_account_move.yml
1 -
2   In order to test the account move lines in OpenERP, I create account move 
3 -
4   I create a Account tax code
5 -
6   !record {model: account.tax.code, id: account_tax_code_0}:
7     name : Tax Code Test
8     sign : 1.00
9 -
10   In order to test the 'Post Journal Entries' wizard in OpenERP, I created an account move
11 -
12   !record {model: account.move, id: account_move_0}:
13     date: !eval time.strftime('%Y-%m-%d')
14     period_id: account.period_6
15     journal_id: account.bank_journal
16     line_id:
17       - account_id: account.cash
18         amount_currency: 0.0
19         credit: 2000.0
20         debit: 0.0
21         name: Basic Computer
22         partner_id: base.res_partner_12
23         ref: '2011010'
24         tax_amount: 0.0
25     name: /
26     ref: '2011010'
27     state: draft
28 -
29   I create another move line
30 -
31   !python {model: account.move.line}: |
32     import time
33     date = self._get_date(cr, uid, {'lang': u'en_US', 'normal_view': False, 'active_model': 'ir.ui.menu',
34       'search_default_journal_id': 1, 'journal_type': 'sale', 'search_default_period_id': 6, 'journal_id': 1, 'view_mode': False,
35       'visible_id': 1, 'period_id': 6, 'tz': False, 'active_ids': [ref('menu_eaction_account_moves_sale')],
36       'search_default_posted': 0, 'active_id': ref('menu_eaction_account_moves_sale')})
37     partner = self.onchange_partner_id(cr, uid, [], False, ref('base.res_partner_12'), ref('account.cash'), debit=0, credit=2000, date=date, journal=False)
38     account = self.onchange_account_id(cr, uid, [], account_id=ref('account.a_recv'), partner_id= ref('base.res_partner_12'))
39     vals = {
40         'journal_id': ref('account.bank_journal'),
41         'period_id': ref('account.period_6'),
42         'ref': '2011010',
43         'tax_code_id': ref('account_tax_code_0'),
44         'tax_amount': 0.0,
45         'account_id': ref('account.a_recv'),
46         'amount_currency': 0.0,
47         'credit': 0.0,
48         'date': time.strftime('%Y-%m-%d'),
49         'debit': 2000.0,
50         'name': 'Basic Computer',
51         'partner_id': ref('base.res_partner_12'),
52         'quantity': 0.0,
53         'move_id': ref('account_move_0'),
54         'date_maturity': partner['value']['date_maturity'],
55         'account_tax_id': account['value']['account_tax_id']
56     }
57     line_id = self.create(cr, uid, vals)
58     assert line_id, "Account move line has not been created"
59 -
60   I check the balance in Journal Items
61 -
62   !python {model: account.move.line}: |
63     ids = self._balance_search(cr, uid, self, 'balance', [('balance', '=', 2000.0)], None, {'lang': u'en_US', 'tz': False, 'active_model': 'ir.ui.menu',
64     'search_default_journal_id': 1, 'journal_type': 'sale', 'search_default_period_id': 6, 'view_mode': False, 'visible_id': 1,
65     'active_ids': [ref('menu_eaction_account_moves_sale')], 'search_default_posted': 0, 'active_id': ref('menu_eaction_account_moves_sale')})
66     bal = self._balance(cr, uid, ids[0][2], 'balance', None,{'lang': u'en_US', 'tz': False, 'active_model': 'ir.ui.menu',
67       'search_default_journal_id': 1, 'journal_type': 'sale', 'search_default_period_id': 6, 'view_mode': False,
68       'visible_id': 1, 'active_ids': [ref('menu_eaction_account_moves_sale')], 'search_default_posted': 0,
69       'active_id': ref('menu_eaction_account_moves_sale')})
70     assert bal, 'Balance has not been computed correctly'
71 -
72   I check that Initially account move state is "Draft"
73 -
74   !assert {model: account.move, id: account_move_0, string: initialstatedraft}:
75     - state == 'draft'
76 -
77   I validate this account move by using the 'Post Journal Entries' wizard
78 -
79   !record {model: validate.account.move, id: validate_account_move_0}:
80     journal_id: account.bank_journal
81     period_id: account.period_6
82 -
83   I click on validate Button
84 -
85   !python {model: validate.account.move}: |
86     self.validate_move(cr, uid, [ref("validate_account_move_0")], {"lang": "en_US", "active_model": "ir.ui.menu",
87       "active_ids": [ref("account.menu_validate_account_moves")], "tz": False, "active_id": ref("account.menu_validate_account_moves"), })
88 -
89   I check that the move state is now "Posted"
90 -
91   !assert {model: account.move, id: account_move_0, string: moveincorrect}:
92     - state == 'posted'
93 -
94   I reconcile the entries partially through "Reconcile Entries" wizard
95 -
96   !record {model: account.move.line.reconcile, id: account_move_line_reconcile0}:
97     trans_nbr: 1
98     credit: 0.0
99     debit: 2000.0
100     writeoff: 2000.0
101 -
102   Then I click on the 'Partial Reconcile' button
103 -
104   !python {model: account.move.line.reconcile}: |
105     move_line_obj = self.pool.get('account.move.line')
106     ids = move_line_obj.search(cr, uid, [('move_id', '=', ref('account_move_0')),('credit', '=', 2000)])
107     partial_reconcile = self.trans_rec_reconcile_partial_reconcile(cr, uid, [ref('account_move_line_reconcile0')], {'lang': u'en_US',
108       'active_model': 'account.move.line', 'active_ids': ids, 'tz': False, 'active_id': ids[0]})
109     move_line = move_line_obj.browse(cr, uid, ids)
110     assert move_line[0].reconcile_partial_id, "Partial reconcilation is not done"