[IMP] l10n_it_edi_sdicoop: Added handling of duplicate sending
Duplicate sending should be considered as positive outcome. We also post a message on the invoice to make the user aware. closes odoo/odoo#87292 X-original-commit: b49210bdf507850306d6f19306ea8cd6a91e3316 Signed-off-by: Josse Colpaert <jco@odoo.com>
This commit is contained in:
@@ -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': _(
|
||||
|
||||
Reference in New Issue
Block a user