From 6b031e79254cc2da8f22f07d84aa77a33477a676 Mon Sep 17 00:00:00 2001 From: Stanislas Gueniffey Date: Fri, 2 Dec 2022 14:56:11 +0000 Subject: [PATCH] [FIX] account_edi: also cancel non-invoice moves Enables the EDI postprocessing method to cancel non-invoice moves. This is useful for entry moves such as withholds in l10n_ec X-original-commit: 1c515e1f55ea675df3f6aace7f6537889779779c Part-of: odoo/odoo#113302 Co-authored-by: Josse Colpaert --- addons/account_edi/models/account_edi_document.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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()