Skip to content

Commit

Permalink
[FIX] account: add a test on settings change
Browse files Browse the repository at this point in the history
Because of f206714 and subsequent commits, adding groups may raise.
We ensure that switching between tax included and tax excluded keeps working.

Closes 37481

closes #37517

Signed-off-by: Nans Lefebvre (len) <len@odoo.com>
  • Loading branch information
Nans Lefebvre committed Sep 30, 2019
1 parent 80fbb53 commit ea574fe
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions addons/account/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from . import test_product_id_change
from . import test_reconciliation
from . import test_search
from . import test_settings
from . import test_tax
from . import test_account_move_taxes_edition
from . import test_templates_consistency
Expand Down
34 changes: 34 additions & 0 deletions addons/account/tests/test_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from odoo.addons.account.tests.account_test_classes import AccountingTestCase
from odoo.tests import tagged


@tagged('post_install', '-at_install')
class TestSettings(AccountingTestCase):

def test_switch_taxB2B_taxB2C(self):
"""
Since having users both in the tax B2B and tax B2C groups raise,
modifications of the settings must be done in the right order;
otherwise it is impossible to change the settings.
"""
# at each setting change, all users should be removed from one group and added to the other
# so picking an arbitrary witness should be equivalent to checking that everything worked.
config = self.env['res.config.settings'].create({})

config.show_line_subtotals_tax_selection = "tax_excluded"
config._onchange_sale_tax()
config.execute()
self.assertEqual(self.env.user.has_group('account.group_show_line_subtotals_tax_excluded'), True)
self.assertEqual(self.env.user.has_group('account.group_show_line_subtotals_tax_included'), False)

config.show_line_subtotals_tax_selection = "tax_included"
config._onchange_sale_tax()
config.execute()
self.assertEqual(self.env.user.has_group('account.group_show_line_subtotals_tax_excluded'), False)
self.assertEqual(self.env.user.has_group('account.group_show_line_subtotals_tax_included'), True)

config.show_line_subtotals_tax_selection = "tax_excluded"
config._onchange_sale_tax()
config.execute()
self.assertEqual(self.env.user.has_group('account.group_show_line_subtotals_tax_excluded'), True)
self.assertEqual(self.env.user.has_group('account.group_show_line_subtotals_tax_included'), False)

0 comments on commit ea574fe

Please sign in to comment.