From 3751379f1e9a4c215fb6eb898b4ccc67659b9ace Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 10 May 2022 21:51:50 +0700 Subject: initial commit 2 --- addons/account/tests/test_account_tax.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 addons/account/tests/test_account_tax.py (limited to 'addons/account/tests/test_account_tax.py') diff --git a/addons/account/tests/test_account_tax.py b/addons/account/tests/test_account_tax.py new file mode 100644 index 00000000..94bd2a16 --- /dev/null +++ b/addons/account/tests/test_account_tax.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +from odoo.addons.account.tests.common import AccountTestInvoicingCommon +from odoo.tests import tagged +from odoo.exceptions import UserError + + +@tagged('post_install', '-at_install') +class TestAccountTax(AccountTestInvoicingCommon): + + def test_changing_tax_company(self): + ''' Ensure you can't change the company of an account.tax if there are some journal entries ''' + + # Avoid duplicate key value violates unique constraint "account_tax_name_company_uniq". + self.company_data['default_tax_sale'].name = 'test_changing_account_company' + + self.env['account.move'].create({ + 'move_type': 'out_invoice', + 'date': '2019-01-01', + 'invoice_line_ids': [ + (0, 0, { + 'name': 'invoice_line', + 'quantity': 1.0, + 'price_unit': 100.0, + 'tax_ids': [(6, 0, self.company_data['default_tax_sale'].ids)], + }), + ], + }) + + with self.assertRaises(UserError), self.cr.savepoint(): + self.company_data['default_tax_sale'].company_id = self.company_data_2['company'] -- cgit v1.2.3