[IMP] account:checked methods of account.move and account.tax.code in yaml
authorMeera Trambadia (OpenERP) <mtr@tinyerp.com>
Wed, 28 Sep 2011 05:23:43 +0000 (10:53 +0530)
committerMeera Trambadia (OpenERP) <mtr@tinyerp.com>
Wed, 28 Sep 2011 05:23:43 +0000 (10:53 +0530)
bzr revid: mtr@tinyerp.com-20110928052343-v9p013w0m29s3auw

addons/account/test/account_supplier_invoice.yml

index 7d1a54c..f067243 100644 (file)
@@ -1,6 +1,26 @@
 -
   In order to test account invoice I create a new supplier invoice
 -
+  I create a Tax Codes
+-
+  !record {model: account.tax.code, id: tax_case}:
+    name: Tax_case
+    company_id: base.main_company
+    sign: 1
+-
+  I create a Tax
+-
+  !record {model: account.tax, id: tax10}:
+    name: Tax 10.0
+    amount: 10.0
+    type: fixed
+    sequence: 1
+    company_id: base.main_company
+    type_tax_use: all
+    tax_code_id: tax_case
+-
+  I create a supplier invoice
+-
   !record {model: account.invoice, id: account_invoice_supplier0}:
     account_id: account.a_pay
     address_contact_id: base.res_partner_address_3000
@@ -15,6 +35,8 @@
         product_id: product.product_product_pc1
         quantity: 10.0
         uos_id: product.product_uom_unit
+        invoice_line_tax_id:
+                  - tax10
     journal_id: account.expenses_journal
     partner_id: base.res_partner_desertic_hispafuentes
     reference_type: none
   I check that the invoice state is now "Open"
 -
   !assert {model: account.invoice, id: account_invoice_supplier0}:
-    - state == 'open'
\ No newline at end of file
+    - state == 'open'
+-
+  I verify that account move is created
+-
+  !python {model: account.invoice}: |
+    move_obj = self.pool.get('account.move')
+    inv = self.browse(cr, uid, ref('account_invoice_supplier0'))
+    move = move_obj.browse(cr, uid, [inv.move_id.id])[0]
+    get_period = move_obj._get_period(cr, uid, {'lang': u'en_US', 'active_model': 'ir.ui.menu',
+      'active_ids': [ref('menu_action_move_journal_line_form')], 'tz': False, 'active_id': ref('menu_action_move_journal_line_form')})
+    amt = move_obj._search_amount(cr, uid, move_obj, 'amount', [('amount', '=', 3100.0)], {'lang': u'en_US', 'active_model': 'ir.ui.menu',
+      'active_ids': [ref('menu_action_move_journal_line_form')], 'tz': False, 'active_id': ref('menu_action_move_journal_line_form')})
+    search_ids = amt[0][2]
+    amt_compute = move_obj._amount_compute(cr, uid, list(search_ids), 'amount', None, {'lang': u'en_US', 'active_model': 'ir.ui.menu',
+      'active_ids': [ref('menu_action_move_journal_line_form')], 'tz': False, 'active_id': ref('menu_action_move_journal_line_form')}, where ='')
+    move_amount = amt_compute.values()
+    assert(inv.move_id and move.period_id.id == get_period and move_amount[0] == 3100.0), ('Journal Entries has not been created')
+-
+  I cancel the account move which is in posted state and verifies that it gives warning message
+-
+  !python {model: account.move}: |
+    inv_obj = self.pool.get('account.invoice')
+    inv = inv_obj.browse(cr, uid, ref('account_invoice_supplier0'))
+    try:
+      mov_cancel = self.button_cancel(cr, uid, [inv.move_id.id], {'lang': u'en_US', 'tz': False,
+        'active_model': 'ir.ui.menu', 'journal_type': 'purchase', 'active_ids': [ref('menu_action_invoice_tree2')],
+        'type': 'in_invoice', 'active_id': ref('menu_action_invoice_tree2')})
+    except Exception, e:
+      assert e, _('Warning message has not been raised')
+-
+  I verify that 'Period Sum' and 'Year sum' of account tax codes gets bind with the values
+-
+  !python {model: account.tax.code}: |
+    tax_code = self.browse(cr, uid, ref('tax_case'))
+    assert(tax_code.sum_period == 100.0 and tax_code.sum == 100.0), _("'Period Sum' and 'Year sum' has not been binded with the correct values")