From 02d165a08240178451688d95f8b0851e4fd4e47a Mon Sep 17 00:00:00 2001 From: sergiocorato Date: Wed, 14 Aug 2019 12:45:53 +0200 Subject: [PATCH] [10.0][FIX] tests not working [FIX] test [IMP] test [FIX] pep8 --- .../test/test_contract_show_invoice.py | 32 --------- .../{test => tests}/__init__.py | 0 .../tests/test_contract_show_invoice.py | 68 +++++++++++++++++++ 3 files changed, 68 insertions(+), 32 deletions(-) delete mode 100644 contract_show_invoice/test/test_contract_show_invoice.py rename contract_show_invoice/{test => tests}/__init__.py (100%) create mode 100644 contract_show_invoice/tests/test_contract_show_invoice.py diff --git a/contract_show_invoice/test/test_contract_show_invoice.py b/contract_show_invoice/test/test_contract_show_invoice.py deleted file mode 100644 index d46295a5..00000000 --- a/contract_show_invoice/test/test_contract_show_invoice.py +++ /dev/null @@ -1,32 +0,0 @@ -# -*- coding: utf-8 -*- -# © 2016 Carlos Dauden -# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html - -from odoo.tests.common import TransactionCase - - -class TestContractShowInvoice(TransactionCase): - def setUp(self): - super(TestContractShowInvoice, self).setUp() - self.analytic_account = self.env['account.analytic.account'].create({ - 'name': 'Test contract show invoice', - }) - self.invoice = self.env['account.invoice'].create( - {'partner_id': self.env.ref('base.res_partner_2').id, - 'type': 'out_invoice', - }) - self.invoice._onchange_partner_id() - self.invoice_line = self.env['account.invoice.line'].create( - {'product_id': self.env.ref('product.product_product_2').id, - 'quantity': 1.0, - 'invoice_id': self.invoice.id, - 'account_analytic_id': self.analytic_account.id, - }) - self.invoice_line._onchange_product_id() - - def test_contract_show_invoice(self): - self.assertEqual(len(self.analytic_account.analytic_account_ids), 1) - - def test_contract_total_invoiced(self): - self.assertEqual(self.invoice.amount_total, - self.analytic_account.total_invoiced) diff --git a/contract_show_invoice/test/__init__.py b/contract_show_invoice/tests/__init__.py similarity index 100% rename from contract_show_invoice/test/__init__.py rename to contract_show_invoice/tests/__init__.py diff --git a/contract_show_invoice/tests/test_contract_show_invoice.py b/contract_show_invoice/tests/test_contract_show_invoice.py new file mode 100644 index 00000000..e2519b60 --- /dev/null +++ b/contract_show_invoice/tests/test_contract_show_invoice.py @@ -0,0 +1,68 @@ +# -*- coding: utf-8 -*- +# © 2016 Carlos Dauden +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from odoo.tests.common import TransactionCase + + +class TestContractShowInvoice(TransactionCase): + def setUp(self): + super(TestContractShowInvoice, self).setUp() + self.analytic_account = self.env['account.analytic.account'].create({ + 'name': 'Test contract show invoice', + }) + self.invoice = self.env['account.invoice'].create( + {'partner_id': self.env.ref('base.res_partner_2').id, + 'type': 'out_invoice', + }) + self.invoice.journal_id.update_posted = True + self.invoice._onchange_partner_id() + self.a_sale = self.env['account.account'].search([ + ('user_type_id', '=', + self.env.ref('account.data_account_type_revenue').id) + ], limit=1) + self.invoice_line = self.env['account.invoice.line'].create( + {'product_id': self.env.ref('product.product_product_2').id, + 'quantity': 1.0, + 'invoice_id': self.invoice.id, + 'account_analytic_id': self.analytic_account.id, + 'account_id': self.a_sale.id, + 'price_unit': 50.0, + 'name': 'Invoice line with analytic account', + 'invoice_line_tax_ids': [(4, self.env['account.tax'].search( + [('type_tax_use', '=', 'sale')], limit=1).id, 0)] + }) + self.invoice.compute_taxes() + self.invoice.action_invoice_open() + + def test_invoice_two_line(self): + self.assertEqual( + self.analytic_account.total_invoiced, + self.invoice_line.price_subtotal, + msg="Amount invoiced is different from single invoice line wich " + "has analytic account") + self.invoice.action_invoice_cancel() + self.invoice.action_invoice_draft() + self.invoice_line1 = self.env['account.invoice.line'].create( + {'product_id': self.env.ref('product.product_product_2').id, + 'quantity': 2.0, + 'invoice_id': self.invoice.id, + 'account_analytic_id': False, + 'account_id': self.a_sale.id, + 'price_unit': 100.0, + 'name': 'Invoice line without analytic account', + 'invoice_line_tax_ids': [(4, self.env['account.tax'].search( + [('type_tax_use', '=', 'sale')], limit=1).id, 0)] + }) + self.invoice.compute_taxes() + self.invoice.action_invoice_open() + self.assertFalse(self.invoice_line1.account_analytic_id, + msg="Invoice line has analytic account") + self.assertEqual(len(self.invoice.analytic_account_ids), 1, + msg="Invoice lines with analytic account are more " + "than one") + self.assertEqual( + self.analytic_account.total_invoiced, + self.invoice_line.price_subtotal, + msg="Amount invoiced is different from invoice lines wich " + "has analytic account")