[FIX] l10n_it_edi: avoid conflict with peppol when switching to demo

Peppol and Italian edi both uses a proxy user. We should only use Italian
proxy users when checking demo mode otherwise Peppol production proxy users
can interfere and trigger an error like 'Company already have prod connection'.
Also we don't want to delete demo Peppol connections.

opw-3675908

closes odoo/odoo#149276

X-original-commit: 078543cfe34427fe96932536bc283fcdf2ce2251
Signed-off-by: Laurent Smet (las) <las@odoo.com>
Signed-off-by: Thomas Beckers (tbs) <tbs@odoo.com>
This commit is contained in:
Thomas Beckers
2024-01-13 15:26:30 +00:00
parent 06bf2e0ec5
commit ad6b9a16fd
@@ -62,6 +62,7 @@ class ResConfigSettings(models.TransientModel):
real_proxy_users = self.env['account_edi_proxy_client.user'].sudo().search([
('company_id', '=', config.company_id.id),
('proxy_type', '=', 'l10n_it_edi'),
('id_client', 'not like', 'demo'),
])
@@ -85,6 +86,7 @@ class ResConfigSettings(models.TransientModel):
elif proxy_user.id_client[:4] == 'demo' and edi_mode != 'demo':
self.env['account_edi_proxy_client.user'].search([
('company_id', '=', config.company_id.id),
('proxy_type', '=', 'l10n_it_edi'),
('id_client', '=like', 'demo%'),
]).sudo().unlink()
self._create_proxy_user(config.company_id, edi_mode)