a59ede03e4ee20f80885e3851fe024a7d1919b87
[odoo/odoo.git] / addons / account / test / account_supplier_invoice.yml
1 -
2   Test with that Finance manager who can only create supplier invoice. 
3 -
4   !context
5     uid: 'res_users_account_manager'
6 -
7   In order to test account invoice I create a new supplier invoice
8 -
9   I create a Tax Codes
10 -
11   !record {model: account.tax.code, id: tax_case}:
12     name: Tax_case
13     company_id: base.main_company
14     sign: 1
15 -
16   I create a Tax
17 -
18   !record {model: account.tax, id: tax10}:
19     name: Tax 10.0
20     amount: 10.0
21     type: fixed
22     sequence: 1
23     company_id: base.main_company
24     type_tax_use: all
25     tax_code_id: tax_case
26 -
27   I create a supplier invoice
28 -
29   !record {model: account.invoice, id: account_invoice_supplier0, view: invoice_supplier_form}:
30     account_id: account.a_pay
31     check_total: 3000.0
32     company_id: base.main_company
33     currency_id: base.EUR
34     invoice_line:
35       - account_id: account.a_expense
36         name: '[PCSC234] PC Assemble SC234'
37         price_unit: 300.0
38         product_id: product.product_product_3
39         quantity: 10.0
40         uos_id: product.product_uom_unit
41         invoice_line_tax_id:
42                   - tax10
43     journal_id: account.expenses_journal
44     partner_id: base.res_partner_12
45     reference_type: none
46     type: in_invoice
47 -
48   I check that Initially supplier invoice state is "Draft"
49 -
50   !assert {model: account.invoice, id: account_invoice_supplier0}:
51     - state == 'draft'
52 -
53   I change the state of invoice to open by clicking Validate button
54 -
55   !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_supplier0}
56 -
57   I check that the invoice state is now "Open"
58 -
59   !assert {model: account.invoice, id: account_invoice_supplier0}:
60     - state == 'open'
61 -
62   I verify that account move is created
63 -
64   !python {model: account.invoice}: |
65     move_obj = self.pool.get('account.move')
66     inv = self.browse(cr, uid, ref('account_invoice_supplier0'))
67     move = inv.move_id
68     get_period = move_obj._get_period(cr, uid, {'lang': u'en_US', 'active_model': 'ir.ui.menu',
69       'active_ids': [ref('menu_action_move_journal_line_form')], 'tz': False, 'active_id': ref('menu_action_move_journal_line_form')})
70     amt = move_obj._search_amount(cr, uid, move_obj, 'amount', [('amount', '=', 3100.0)], {'lang': u'en_US', 'active_model': 'ir.ui.menu',
71       'active_ids': [ref('menu_action_move_journal_line_form')], 'tz': False, 'active_id': ref('menu_action_move_journal_line_form')})
72     ids = amt[0][2]
73     amt_compute = move_obj._amount_compute(cr, uid, list(ids), 'amount', None, {'lang': u'en_US', 'active_model': 'ir.ui.menu',
74       'active_ids': [ref('menu_action_move_journal_line_form')], 'tz': False, 'active_id': ref('menu_action_move_journal_line_form')}, where ='')
75     move_amount = amt_compute.values()
76     assert(inv.move_id and move.period_id.id == get_period and move_amount[0] == 3100.0), ('Journal Entries has not been created')
77 -
78   I cancel the account move which is in posted state and verifies that it gives warning message
79 -
80   !python {model: account.move}: |
81     from openerp.osv import osv
82     inv_obj = self.pool.get('account.invoice')
83     inv = inv_obj.browse(cr, uid, ref('account_invoice_supplier0'))
84     try:
85       mov_cancel = self.button_cancel(cr, uid, [inv.move_id.id], {'lang': u'en_US', 'tz': False,
86         'active_model': 'ir.ui.menu', 'journal_type': 'purchase', 'active_ids': [ref('menu_action_invoice_tree2')],
87         'type': 'in_invoice', 'active_id': ref('menu_action_invoice_tree2')})
88       assert False, "This should never happen!"
89     except osv.except_osv:
90       pass
91 -
92   I verify that 'Period Sum' and 'Year sum' of the tax code are the expected values 
93 -
94   !python {model: account.tax.code}: |
95     tax_code = self.browse(cr, uid, ref('tax_case'))
96     assert(tax_code.sum_period == 100.0 and tax_code.sum == 100.0), "Incorrect 'Period Sum' / 'Year sum' expected twice 100.0, got period=%r and year=%r)" % (tax_code.sum_period,tax_code.sum)