From c27d3281b03aa12fb7fab848e7813e82eaee06ab Mon Sep 17 00:00:00 2001 From: "Paolo Gatti (pgi)" Date: Wed, 27 Sep 2023 15:42:50 +0000 Subject: [PATCH] [FIX] l10n_it_edi: register proxy user per company fix We have switched from a config_parameter (all companies rely on the same) to account_edi_proxy_client_user.edi_mode which is company based in `saas-16.3`. We forgot to add the company to the domain while searching for existing for test proxy users when changing the field in the res_config_settings. So if it finds a test user "in any company" it still blocks you. See: #116059 Task link: https://www.odoo.com/web#id=3525461&model=project.task task-35225461 closes odoo/odoo#137012 X-original-commit: 63595f4bb1bc069387579f512082f128d1484fe5 Signed-off-by: Josse Colpaert Signed-off-by: Paolo Gatti (pgi) --- addons/l10n_it_edi/models/res_config_settings.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/addons/l10n_it_edi/models/res_config_settings.py b/addons/l10n_it_edi/models/res_config_settings.py index 8c1c5862d45..f0e167a85ea 100644 --- a/addons/l10n_it_edi/models/res_config_settings.py +++ b/addons/l10n_it_edi/models/res_config_settings.py @@ -32,10 +32,6 @@ class ResConfigSettings(models.TransientModel): ], limit=1) config.l10n_it_edi_demo_mode = edi_user.edi_mode - def _set_l10n_it_edi_demo_mode(self): - for config in self: - self.env['ir.config_parameter'].set_param('account_edi_proxy_client.demo', config.l10n_it_edi_demo_mode) - @api.depends('company_id.account_edi_proxy_client_ids', 'company_id.account_edi_proxy_client_ids.active') def _compute_is_edi_proxy_active(self): for config in self: @@ -65,13 +61,14 @@ class ResConfigSettings(models.TransientModel): ], limit=1) real_proxy_users = self.env['account_edi_proxy_client.user'].sudo().search([ + ('company_id', '=', config.company_id.id), ('id_client', 'not like', 'demo'), ]) # Update the config as per the selected radio button previous_demo_state = proxy_user.edi_mode edi_mode = config.l10n_it_edi_demo_mode - self.env['ir.config_parameter'].set_param('account_edi_proxy_client.demo', edi_mode) + # If the user is trying to change from a state in which they have a registered official or testing proxy client # to another state, we should stop them if real_proxy_users and previous_demo_state != edi_mode: @@ -86,5 +83,8 @@ class ResConfigSettings(models.TransientModel): # If there is a demo user, and we are transitioning from demo to test or production, we should # delete all demo users and then create the new user. elif proxy_user.id_client[:4] == 'demo' and edi_mode != 'demo': - self.env['account_edi_proxy_client.user'].search([('id_client', '=like', 'demo%')]).sudo().unlink() + self.env['account_edi_proxy_client.user'].search([ + ('company_id', '=', config.company_id.id), + ('id_client', '=like', 'demo%'), + ]).sudo().unlink() self._create_proxy_user(config.company_id, edi_mode)