You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.9 KiB

9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
  1. # -*- coding: utf-8 -*-
  2. # © 2016 Lorenzo Battistini - Agile Business Group
  3. # © 2016 Giovanni Capalbo <giovanni@therp.nl>
  4. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  5. from openerp.tests.common import TransactionCase
  6. class TestAccountTaxBalance(TransactionCase):
  7. def test_tax_balance(self):
  8. tax_account_id = self.env['account.account'].search(
  9. [('name', '=', 'Tax Paid')], limit=1).id
  10. tax = self.env['account.tax'].create({
  11. 'name': 'Tax 10.0',
  12. 'amount': 10.0,
  13. 'amount_type': 'fixed',
  14. 'account_id': tax_account_id,
  15. })
  16. invoice_account_id = self.env['account.account'].search(
  17. [('user_type_id', '=', self.env.ref(
  18. 'account.data_account_type_receivable'
  19. ).id)], limit=1).id
  20. invoice_line_account_id = self.env['account.account'].search(
  21. [('user_type_id', '=', self.env.ref(
  22. 'account.data_account_type_expenses').id)], limit=1).id
  23. invoice = self.env['account.invoice'].create({
  24. 'partner_id': self.env.ref('base.res_partner_2').id,
  25. 'account_id': invoice_account_id,
  26. 'type': 'out_invoice',
  27. })
  28. self.env['account.invoice.line'].create({
  29. 'product_id': self.env.ref('product.product_product_4').id,
  30. 'quantity': 1.0,
  31. 'price_unit': 100.0,
  32. 'invoice_id': invoice.id,
  33. 'name': 'product that cost 100',
  34. 'account_id': invoice_line_account_id,
  35. 'invoice_line_tax_ids': [(6, 0, [tax.id])],
  36. })
  37. invoice._onchange_invoice_line_ids()
  38. invoice._convert_to_write(invoice._cache)
  39. self.assertEqual(invoice.state, 'draft')
  40. # change the state of invoice to open by clicking Validate button
  41. invoice.signal_workflow('invoice_open')
  42. self.assertEquals(tax.base_balance, -100)
  43. self.assertEquals(tax.balance, -10)