diff --git a/addons/account_edi/models/account_edi_document.py b/addons/account_edi/models/account_edi_document.py index 7a3a5b1b461..10de7724c3d 100644 --- a/addons/account_edi/models/account_edi_document.py +++ b/addons/account_edi/models/account_edi_document.py @@ -141,7 +141,7 @@ class AccountEdiDocument(models.Model): attachments_to_unlink.unlink() def _postprocess_cancel_edi_results(documents, edi_result): - invoice_ids_to_cancel = set() # Avoid duplicates + move_ids_to_cancel = set() # Avoid duplicates attachments_to_unlink = self.env['ir.attachment'] for document in documents: move = document.move_id @@ -155,10 +155,10 @@ class AccountEdiDocument(models.Model): 'blocking_level': False, }) - if move.is_invoice(include_receipts=True) and move.state == 'posted': + if move.state == 'posted': # The user requested a cancellation of the EDI and it has been approved. Then, the invoice # can be safely cancelled. - invoice_ids_to_cancel.add(move.id) + move_ids_to_cancel.add(move.id) if not old_attachment.res_model or not old_attachment.res_id: attachments_to_unlink |= old_attachment @@ -169,8 +169,8 @@ class AccountEdiDocument(models.Model): 'blocking_level': move_result.get('blocking_level', DEFAULT_BLOCKING_LEVEL) if move_result.get('error') else False, }) - if invoice_ids_to_cancel: - invoices = self.env['account.move'].browse(list(invoice_ids_to_cancel)) + if move_ids_to_cancel: + invoices = self.env['account.move'].browse(list(move_ids_to_cancel)) invoices.button_draft() invoices.button_cancel()