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