From b1996a3676d1f5f54202379a9a6f71601e608c6c Mon Sep 17 00:00:00 2001 From: Katherine Zaoral Date: Wed, 4 Jan 2023 13:40:22 +0000 Subject: [PATCH] [IMP] l10n_ar_account_withholding: when to show help padron Si no pudimos obtener la informacion del padron arba mostramos el error avisando que es un error de dicho padron y damos la opcion al cliente de cargarlo manualmente closes ingadhoc/odoo-argentina#665 Signed-off-by: Ignacio Cainelli --- .../models/res_company.py | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/l10n_ar_account_withholding/models/res_company.py b/l10n_ar_account_withholding/models/res_company.py index d5f27f76e..2f60e442e 100644 --- a/l10n_ar_account_withholding/models/res_company.py +++ b/l10n_ar_account_withholding/models/res_company.py @@ -146,13 +146,12 @@ def get_arba_data(self, partner, from_date, to_date): to_date.strftime('%Y%m%d'), cuit) + error = False + msg = False if ws.Excepcion: - action = self.env.ref('l10n_ar_account_withholding.act_company_jurisdiction_padron') - raise RedirectWarning(_( - "Obtuvimos un error de conexión con ARBA y no encontramos padrón almacenado para las fechas dadas.\n" - "Puede intentar nuevamente más tarde, cargar la alícuota manualmente en el partner o subir el archivo del padrón en: "), - action.id, _('Ir a Carga de Padrones')) - # raise UserError("%s\nExcepcion: %s" % (ws.Traceback, ws.Excepcion)) + error = True + msg = str((ws.Traceback, ws.Excepcion)) + _logger.error('Padron ARBA: Excepcion %s' % msg) # ' Hubo error general de ARBA? if ws.CodigoError: @@ -160,9 +159,21 @@ def get_arba_data(self, partner, from_date, to_date): # we still create the record so we don need to check it again # on same period _logger.info('CUIT %s not present on padron ARBA' % cuit) + if ws.CodigoError == '6': + error = True + msg = "%s\n Error %s: %s" % (ws.MensajeError, ws.TipoError, ws.CodigoError) + _logger.error('Padron ARBA: %s' % msg) else: - raise UserError("%s\nError %s: %s" % ( - ws.MensajeError, ws.TipoError, ws.CodigoError)) + raise UserError("Padron ARBA: %s\nError %s: %s" % (ws.MensajeError, ws.TipoError, ws.CodigoError)) + + if error: + action = self.env.ref('l10n_ar_account_withholding.act_company_jurisdiction_padron') + raise RedirectWarning(_( + "Obtuvimos un error al consultar el Padron ARBA.\n %s\n\n" + "Tiene las siguientes opciones:\n 1) Intentar nuevamente más tarde\n" + " 2) Cargar la alícuota manualmente en el partner en cuestión\n" + " 3) Subir el archivo del padrón utilizando el asistente de Carga de Padrones") % msg, + action.id, _('Ir a Carga de Padrones')) # no ponemos esto, si no viene alicuota es porque es cero entonces # if not ws.AlicuotaRetencion or not ws.AlicuotaPercepcion: