From 355878cfb7b431df8b78af8977cfad61a10bba12 Mon Sep 17 00:00:00 2001 From: "Paolo Gatti (pgi)" Date: Tue, 6 Feb 2024 11:12:36 +0100 Subject: [PATCH] [FIX] l10n_it_edi: Errors in warnings_message -> actionable errors migration code The compatibility was broken in a couple of points, clients are required to update the `l10n_it_edi` or cannot send invoices to the Italian EDI. Updating the module fixes the errors. These two errors may appear: ``` [...] File "/home/odoo/work/odoo/odoo/fields.py", line 1216, in __get__ raise ValueError(f"Compute method failed to assign {missing_recs}.{self.name}") ValueError: Compute method failed to assign account.move.send(,).l10n_it_edi_warning_message [...] File "/home/odoo/work/odoo/addons/l10n_it_edi/wizard/account_move_send.py", line 57, in _compute_l10n_it_edi_warning_message action = error_data['action'] ~~~~~~~~~~^^^^^^^^^^ KeyError: 'action' ``` Original broken PR: odoo/odoo#142596 closes odoo/odoo#152824 Signed-off-by: Josse Colpaert --- addons/l10n_it_edi/wizard/account_move_send.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/addons/l10n_it_edi/wizard/account_move_send.py b/addons/l10n_it_edi/wizard/account_move_send.py index acca4a88a48..fef6a3ad397 100644 --- a/addons/l10n_it_edi/wizard/account_move_send.py +++ b/addons/l10n_it_edi/wizard/account_move_send.py @@ -42,6 +42,7 @@ class AccountMoveSend(models.TransientModel): # To be removed -- Proxy feature to be replaced with actionable_errors as soon as the user updates the module for wizard in self: messages = [] + wizard.l10n_it_edi_warning_message = False if wizard.l10n_it_edi_actionable_errors: messages.append(_("Please upgrade the Italian EDI module to update this widget.")) messages.append(_("Go to Applications page and update the 'Italia - Fatturazione Elettronica' module.")) @@ -54,13 +55,13 @@ class AccountMoveSend(models.TransientModel): 'move': 'account.move', 'company': 'res.company' }.get(split[0], None)): - action = error_data['action'] - if 'res_id' in action: - record_ids = [action['res_id']] - else: - record_ids = action['domain'][0][2] - records = self.env[model_id].browse(record_ids) - message = f"{message} - {', '.join(records.mapped('display_name'))}" + if action := error_data.get('action'): + if 'res_id' in action: + record_ids = [action['res_id']] + else: + record_ids = action['domain'][0][2] + records = self.env[model_id].browse(record_ids) + message = f"{message} - {', '.join(records.mapped('display_name'))}" messages.append(nl2br(escape(message))) wizard.l10n_it_edi_warning_message = Markup("
").join(messages)