diff options
| author | Nans Lefebvre <len@odoo.com> | 2019-09-27 13:20:31 +0000 |
|---|---|---|
| committer | Nans Lefebvre <len@odoo.com> | 2019-10-02 09:28:17 +0000 |
| commit | d46befdf25ad6a1f4c47a0308f2fbadfcfbcc6b7 (patch) | |
| tree | 86f7f09bc635c5d211db73ea4818eb914748b4c1 /addons/account/tests/test_settings.py | |
| parent | a22939532c40031176bc26759253eeed2c1471ec (diff) | |
[FIX] account: add a test on settings change
Because of f206714af08 and subsequent commits, adding groups may raise.
We ensure that switching between tax included and tax excluded keeps working.
Closes #37481
closes odoo/odoo#37633
Forward-port-of: #37517
Signed-off-by: Nans Lefebvre (len) <len@odoo.com>
Diffstat (limited to 'addons/account/tests/test_settings.py')
| -rw-r--r-- | addons/account/tests/test_settings.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/addons/account/tests/test_settings.py b/addons/account/tests/test_settings.py new file mode 100644 index 00000000000..e96b98349ac --- /dev/null +++ b/addons/account/tests/test_settings.py @@ -0,0 +1,37 @@ +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.flush() + 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.flush() + 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.flush() + 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) |
