From ba5b77427dc5fcf0c1307d49b65dd2023ccfd716 Mon Sep 17 00:00:00 2001 From: Nans Lefebvre Date: Wed, 27 Nov 2019 15:48:47 +0000 Subject: [PATCH] [TEST] account: remove group from all users when removing settings Initial issue solved by 3eb06a27dae31ddc4112445801ee4c1c601fe669 We keep the test since it ensures that settings can be saved properly. X-original-commit: 2c1b92f626edaf89c93c3bd96d656aa77c580c69 --- addons/account/tests/test_settings.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/addons/account/tests/test_settings.py b/addons/account/tests/test_settings.py index 793cf71fe5a..854ec90ea79 100644 --- a/addons/account/tests/test_settings.py +++ b/addons/account/tests/test_settings.py @@ -14,7 +14,9 @@ class TestSettings(AccountTestCommon): # 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({}) + self.switch_tax_settings(config) + def switch_tax_settings(self, config): config.show_line_subtotals_tax_selection = "tax_excluded" config._onchange_sale_tax() config.flush() @@ -35,3 +37,23 @@ class TestSettings(AccountTestCommon): 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) + + def test_switch_taxB2B_taxB2C_multicompany(self): + """ + Contrarily to the (apparently reasonable) assumption that adding users + to group and removing them was symmetrical, it may not be the case + if one is done in SQL and the other via the ORM. + Because the latter automatically takes into account record rules that + might make some users invisible. + + This one is identical to the previous, except that we do the actions + with a non-superuser user, and in a new company with one user in common + with another company which has a different taxB2X setting. + """ + user = self.env.ref('base.user_admin') + company = self.env['res.company'].create({'name': 'oobO'}) + user.write({'company_ids': [(4, company.id)], 'company_id': company.id}) + Settings = self.env['res.config.settings'].with_user(user.id) + config = Settings.create({}) + + self.switch_tax_settings(config)