From 888f2a620d2688fd9083907e6a0e5b51dcac4020 Mon Sep 17 00:00:00 2001 From: "elias.mendez" <elias.mendez@openpyme.mx> Date: Mon, 8 May 2023 17:54:08 -0600 Subject: [PATCH] fix(l10n.mx.facturae): se agrega un punto de guardado MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit se agrega un punto de guardado, en caso de que alguna de las facturas presente un error de cancelación las anteriores se cancelen excepto el del error y los iguientes a ello --- l10n_mx_facturae/models/account_invoice.py | 39 ++++++++++++++++------ 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/l10n_mx_facturae/models/account_invoice.py b/l10n_mx_facturae/models/account_invoice.py index 9cf2d1ba34..8d64baaf42 100644 --- a/l10n_mx_facturae/models/account_invoice.py +++ b/l10n_mx_facturae/models/account_invoice.py @@ -361,17 +361,34 @@ class AccountInvoice(models.Model): """Verify cancellation status""" # TODO: Is this really needed? Maybe we can reuse the action_cancel for account_invoice in self: - status_cancelacion = account_invoice.consult_cfdi_cancellation_status() - if status_cancelacion is None: - continue - elif status_cancelacion is False: - self.undo_waiting_state() - else: - try: - account_invoice.action_cancel() - except Exception as e: - _logger.info(e) - continue + try: + with self.env.cr.savepoint(): + status_cancelacion = \ + account_invoice.consult_cfdi_cancellation_status() + if status_cancelacion is None: + account_invoice.message_post( + body=_( + "No status update found on SAT" + ) + ) + elif status_cancelacion is False: + self.undo_waiting_state() + else: + try: + account_invoice.action_cancel() + except Exception as e: + account_invoice.message_post( + body=_( + "The invoice could not be canceled" + ) + ) + except Exception as e: + account_invoice.message_post( + body=_( + "Could not check SAT invoice status " + "due to the following error: %s." + ) % (e) + ) @api.multi def _validate_cfdi_data(self): -- GitLab