diff --git a/addons/l10n_it_edi_sdicoop/models/account_edi_format.py b/addons/l10n_it_edi_sdicoop/models/account_edi_format.py index dea4c4672cd..f6ed849d479 100644 --- a/addons/l10n_it_edi_sdicoop/models/account_edi_format.py +++ b/addons/l10n_it_edi_sdicoop/models/account_edi_format.py @@ -237,9 +237,22 @@ class AccountEdiFormat(models.Model): else: to_return[invoice] = {'attachment': invoice.l10n_it_edi_attachment_id, 'success': True} elif state == 'notificaScarto': - errors = [element.find('Descrizione').text for element in response_tree.xpath('//Errore')] - to_return[invoice] = {'error': self._format_error_message(_('The invoice has been refused by the Exchange System'), errors), 'blocking_level': 'error'} - invoice.l10n_it_edi_transaction = False + elements = response_tree.xpath('//Errore') + error_codes = [element.find('Codice').text for element in elements] + errors = [element.find('Descrizione').text for element in elements] + # Duplicated invoice + if '00404' in error_codes: + idx = error_codes.index('00404') + invoice.message_post(body=_( + 'This invoice number had already been submitted to the SdI, so it is' + ' set as Sent. Please verify that the system is correctly configured,' + ' because the correct flow does not need to send the same invoice' + ' twice for any reason.\n' + ' Original message from the SDI: %s', errors[idx])) + to_return[invoice] = {'attachment': invoice.l10n_it_edi_attachment_id, 'success': True} + else: + to_return[invoice] = {'error': self._format_error_message(_('The invoice has been refused by the Exchange System'), errors), 'blocking_level': 'error'} + invoice.l10n_it_edi_transaction = False elif state == 'notificaMancataConsegna': if invoice._is_commercial_partner_pa(): to_return[invoice] = {'error': _(