[IMP] karma retag checks
[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     from openerp.tools import float_compare
66     move_obj = self.pool.get('account.move')
67     inv = self.browse(cr, uid, ref('account_invoice_supplier0'))
68     move = inv.move_id
69     get_period = move_obj._get_period(cr, uid, {'lang': u'en_US', 'active_model': 'ir.ui.menu',
70       'active_ids': [ref('menu_action_move_journal_line_form')], 'tz': False, 'active_id': ref('menu_action_move_journal_line_form')})
71     amt = move_obj._search_amount(cr, uid, move_obj, 'amount', [('amount', '=', 3100.0)], {'lang': u'en_US', 'active_model': 'ir.ui.menu',
72       'active_ids': [ref('menu_action_move_journal_line_form')], 'tz': False, 'active_id': ref('menu_action_move_journal_line_form')})
73     ids = amt[0][2]
74     amt_compute = move_obj._amount_compute(cr, uid, list(ids), 'amount', None, {'lang': u'en_US', 'active_model': 'ir.ui.menu',
75       'active_ids': [ref('menu_action_move_journal_line_form')], 'tz': False, 'active_id': ref('menu_action_move_journal_line_form')}, where ='')
76     move_amount = amt_compute.values()
77     assert(inv.move_id and move.period_id.id == get_period and float_compare(move_amount[0], 3100.0, precision_digits=2) == 0), ('Journal Entries has not been created')
78 -
79   I cancel the account move which is in posted state and verifies that it gives warning message
80 -
81   !python {model: account.move}: |
82     from openerp.osv import osv
83     inv_obj = self.pool.get('account.invoice')
84     inv = inv_obj.browse(cr, uid, ref('account_invoice_supplier0'))
85     try:
86       mov_cancel = self.button_cancel(cr, uid, [inv.move_id.id], {'lang': u'en_US', 'tz': False,
87         'active_model': 'ir.ui.menu', 'journal_type': 'purchase', 'active_ids': [ref('menu_action_invoice_tree2')],
88         'type': 'in_invoice', 'active_id': ref('menu_action_invoice_tree2')})
89       assert False, "This should never happen!"
90     except osv.except_osv:
91       pass
92 -
93   I verify that 'Period Sum' and 'Year sum' of the tax code are the expected values 
94 -
95   !python {model: account.tax.code}: |
96     from openerp.tools import float_compare
97     tax_code = self.browse(cr, uid, ref('tax_case'))
98     assert(float_compare(tax_code.sum_period, 100.0, precision_digits=2) == 0 and float_compare(tax_code.sum, 100.0, precision_digits=2) == 0), "Incorrect 'Period Sum' / 'Year sum' expected twice 100.0, got period=%r and year=%r)" % (tax_code.sum_period,tax_code.sum)