[FIX] l10n_it_edi: set default 'demo' for l10n_it_edi_sdicoop_demo_mode

This traceback arises when the user tries to activate
'l10n_it_edi_sdicoop_register' without 'l10n_it_edi_sdicoop_demo_mode'.

To reproduce this issue:

1) Install 'l10n_it_edi' without demo data
2) Open 'Invoice/Customers/Customers'
3) Set the value of 'Codice Fiscale' field for all customers
4) Go to the 'Configuration/Settings/Electronic Document Invoicing' block
5) Now activate 'Allow Odoo to process invoices' twice

Error:- "KeyError: False"

[1] On the '_set_l10n_it_edi_sdicoop_register_demo_mode' method,
'edi_mode' variable is getting value through 'l10n_it_edi_sdicoop_demo_mode'.

When the user is not activated 'l10n_it_edi_sdicoop_demo_mode', 'edi_mode'
value will be 'False'.

Here 'edi_mode' is used in '_create_proxy_user' method and in that
'_create_proxy_user' the '_register_proxy_user' method is used, in
which the 'response' variable is getting value with the help of
'_get_server_url'method.

[2] But '_get_server_url' method returns 'proxy_urls[proxy_type][edi_mode]'.

Because the user did not selected'l10n_it_edi_sdicoop_demo_mode',
the 'edi_mode' value will be 'False', Which leads to the above traceback.

This commit will resolve the above issue by selecting default value 'demo',
if no 'l10n_it_edi_sdicoop_demo_mode'.

See:-
[1]
https://github.com/odoo/odoo/blob/8a13ca14d3fd251bbf85b1d8949b9d3c6ea76119/addons/l10n_it_edi/models/res_config_settings.py#L81-L92

[2]
https://github.com/odoo/odoo/blob/8a13ca14d3fd251bbf85b1d8949b9d3c6ea76119/addons/account_edi_proxy_client/models/account_edi_proxy_user.py#L84-L89

Sentry-4457787457

closes odoo/odoo#136771

X-original-commit: d6f9a0015c9f82fd7719883f604ad4d808332485
Signed-off-by: Florian Gilbert (flg) <flg@odoo.com>
Signed-off-by: Altaf Shaik (alsh) <alsh@odoo.com>
This commit is contained in:
alsh-odoo
2023-10-03 06:16:45 +00:00
parent 0ac02c60dc
commit 2331165bd0
@@ -30,7 +30,7 @@ class ResConfigSettings(models.TransientModel):
('company_id', '=', config.company_id.id),
('proxy_type', '=', 'l10n_it_edi'),
], limit=1)
config.l10n_it_edi_demo_mode = edi_user.edi_mode
config.l10n_it_edi_demo_mode = edi_user.edi_mode or 'demo'
@api.depends('company_id.account_edi_proxy_client_ids', 'company_id.account_edi_proxy_client_ids.active')
def _compute_is_edi_proxy_active(self):