diff --git a/account_tax_balance/README.rst b/account_tax_balance/README.rst index 8b9b2905..c5cfc281 100644 --- a/account_tax_balance/README.rst +++ b/account_tax_balance/README.rst @@ -42,6 +42,7 @@ Contributors ------------ * Lorenzo Battistini +* Giovanni Capalbo Maintainer ---------- diff --git a/account_tax_balance/tests/__init__.py b/account_tax_balance/tests/__init__.py index 7094e61d..b1bcc511 100644 --- a/account_tax_balance/tests/__init__.py +++ b/account_tax_balance/tests/__init__.py @@ -1,3 +1,6 @@ -#Accounting tests extending AccountingTestCase +# -*- coding: utf-8 -*- +# © 2016 Lorenzo Battistini - Agile Business Group +# © 2016 Giovanni Capalbo +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from . import test_account_tax_balance +from . import test_account_tax_balance diff --git a/account_tax_balance/tests/test_account_tax_balance.py b/account_tax_balance/tests/test_account_tax_balance.py index 9c7cd74a..edefd417 100644 --- a/account_tax_balance/tests/test_account_tax_balance.py +++ b/account_tax_balance/tests/test_account_tax_balance.py @@ -1,51 +1,33 @@ -#from openerp.addons.account.tests.account_test_users import AccountTestUsers +# -*- coding: utf-8 -*- +# © 2016 Lorenzo Battistini - Agile Business Group +# © 2016 Giovanni Capalbo +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + from openerp.tests.common import TransactionCase -from openerp.tools import float_compare - -class TestAccountTaxBalance(TransactionCase): - - def setUp(self): - super(TestAccountTaxBalance, self).setUp() - self.fixed_tax = self.tax_model.create({ - 'name': "Fixed tax", - 'amount_type': 'fixed', - 'amount': 10.0, - 'sequence': 1, - }) - self.fixed_tax_bis = self.tax_model.create({ - 'name': "Fixed tax bis", - 'amount_type': 'fixed', - 'amount': 15, - 'sequence': 2, - }) - self.percent_tax = self.tax_model.create({ - 'name': "Percent tax", - 'amount_type': 'percent', - 'amount': 10.0, - 'sequence': 3, - }) - self.bank_journal = self.env['account.journal'].search([('type', '=', 'bank'), ('company_id', '=', self.account_manager.company_id.id)])[0] - self.bank_account = self.bank_journal.default_debit_account_id - self.expense_account = self.env['account.account'].search([('user_type_id.type', '=', 'payable')], limit=1) #Should be done by onchange later +class TestAccountTaxBalance(TransactionCase): def test_tax_balance(self): - company_id = self.env['res.users'].browse(self.env.uid).company_id.id + tax_account_id = self.env['account.account'].search( + [('name', '=', 'Tax Paid')], limit=1).id tax = self.env['account.tax'].create({ 'name': 'Tax 10.0', 'amount': 10.0, 'amount_type': 'fixed', + 'account_id': tax_account_id, }) - analytic_account = self.env['account.analytic.account'].create({ - 'name': 'test account', - }) - invoice_account = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_receivable').id)], limit=1).id - invoice_line_account = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_expenses').id)], limit=1).id + invoice_account_id = self.env['account.account'].search( + [('user_type_id', '=', self.env.ref( + 'account.data_account_type_receivable' + ).id)], limit=1).id + invoice_line_account_id = self.env['account.account'].search( + [('user_type_id', '=', self.env.ref( + 'account.data_account_type_expenses').id)], limit=1).id invoice = self.env['account.invoice'].create({ 'partner_id': self.env.ref('base.res_partner_2').id, - 'account_id': invoice_account, - 'type': 'in_invoice', + 'account_id': invoice_account_id, + 'type': 'out_invoice', }) self.env['account.invoice.line'].create({ @@ -54,19 +36,15 @@ class TestAccountTaxBalance(TransactionCase): 'price_unit': 100.0, 'invoice_id': invoice.id, 'name': 'product that cost 100', - 'account_id': invoice_line_account, + 'account_id': invoice_line_account_id, 'invoice_line_tax_ids': [(6, 0, [tax.id])], - 'account_analytic_id': analytic_account.id, }) + invoice._onchange_invoice_line_ids() + invoice._convert_to_write(invoice._cache) + self.assertEqual(invoice.state, 'draft') - # : check that Initially supplier bill state is "Draft" - self.assertTrue((invoice.state == 'draft'), "Initially vendor bill state is Draft") - - #change the state of invoice to open by clicking Validate button + # change the state of invoice to open by clicking Validate button invoice.signal_workflow('invoice_open') - - self.assertEquals(tax.base_balance, 100) - self.assertEquals(tax.balance, 10) - - + self.assertEquals(tax.base_balance, -100) + self.assertEquals(tax.balance, -10) diff --git a/account_tax_balance/wizard/open_tax_balances_view.xml b/account_tax_balance/wizard/open_tax_balances_view.xml index fed17d33..f789ee88 100644 --- a/account_tax_balance/wizard/open_tax_balances_view.xml +++ b/account_tax_balance/wizard/open_tax_balances_view.xml @@ -37,4 +37,4 @@ parent="account.menu_finance_reports" groups="account.group_account_user,account.group_account_manager"> - \ No newline at end of file +