diff --git a/l10n_mx_facturae/models/account_invoice.py b/l10n_mx_facturae/models/account_invoice.py index 9cf2d1ba34a1908dac5e7f18f18943f44b9d168c..8d64baaf42c3dc8fffbeb71dfdbc2565a81492de 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):