From 6e7a0664850ccbc30a7a8a3ced22f05347bc6f9e Mon Sep 17 00:00:00 2001 From: Kamen Zhekov <kzh@odoo.com> Date: Thu, 9 Sep 2021 12:01:10 +0000 Subject: [PATCH] [FIX] website: correctly set and sync custom account setting A while back, the behavior of this setting was changed from a related field to a computed as a fix to various issues with: cb9f48d The setting's value synchronization with what is displayed on the setting's page is broken, since its behavior changed with commit: 2ccc735 . It resets to its default value for the default website when editing a secondary one and is not only confusing but breaks the setting in some scenarios. When changing the auth_signup_uninvited setting, the changes are correctly reflected and not reset to default upon changing the website we are currently editing. task-2612686 closes odoo/odoo#76262 Signed-off-by: Romain Derie (rde) <rde@odoo.com> --- addons/website/models/res_config_settings.py | 4 ++-- addons/website/tests/__init__.py | 1 + addons/website/tests/test_auth_signup_uninvited.py | 13 +++++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 addons/website/tests/test_auth_signup_uninvited.py diff --git a/addons/website/models/res_config_settings.py b/addons/website/models/res_config_settings.py index 9501ab5cf156..9d621f483c58 100644 --- a/addons/website/models/res_config_settings.py +++ b/addons/website/models/res_config_settings.py @@ -68,10 +68,10 @@ class ResConfigSettings(models.TransientModel): google_maps_api_key = fields.Char(related='website_id.google_maps_api_key', readonly=False) group_multi_website = fields.Boolean("Multi-website", implied_group="website.group_multi_website") + @api.onchange('website_id') @api.depends('website_id.auth_signup_uninvited') def _compute_auth_signup(self): - for config in self: - config.auth_signup_uninvited = config.website_id.auth_signup_uninvited + self.auth_signup_uninvited = self.website_id.auth_signup_uninvited def _set_auth_signup(self): for config in self: diff --git a/addons/website/tests/__init__.py b/addons/website/tests/__init__.py index efde81df5007..969122202b54 100644 --- a/addons/website/tests/__init__.py +++ b/addons/website/tests/__init__.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. from . import test_attachment +from . import test_auth_signup_uninvited from . import test_base_url from . import test_converter from . import test_crawl diff --git a/addons/website/tests/test_auth_signup_uninvited.py b/addons/website/tests/test_auth_signup_uninvited.py new file mode 100644 index 000000000000..da3ff7081cec --- /dev/null +++ b/addons/website/tests/test_auth_signup_uninvited.py @@ -0,0 +1,13 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo.tests import common, tagged + + +@tagged('-at_install', 'post_install') +class TestAuthSignupUninvited(common.TransactionCase): + + def test_01_auth_signup_uninvited(self): + self.env['website'].browse(1).auth_signup_uninvited = 'b2c' + config = self.env['res.config.settings'].create({}) + self.assertEqual(config.auth_signup_uninvited, 'b2c') -- GitLab