From 544b087564009e481a86658d6136b01cc05aa5dd Mon Sep 17 00:00:00 2001 From: Katherine Zaoral Date: Mon, 28 Aug 2023 15:04:48 -0300 Subject: [PATCH] [ADD] l10n_uy_edi: CFE UFCE Uuid Change unique identification to only the record and the id, ths way if we have and error on the comunication with the webservices or an error in Odoo itself we are able to resend, chathing error E02 duplicated record and be able to fix it without problem. X-original-commit: 21e86a0109ac51f2eb377b2b52880c93bf11fd8c --- l10n_uy_edi/models/l10n_uy_cfe.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/l10n_uy_edi/models/l10n_uy_cfe.py b/l10n_uy_edi/models/l10n_uy_cfe.py index 17213a67..24a71633 100644 --- a/l10n_uy_edi/models/l10n_uy_cfe.py +++ b/l10n_uy_edi/models/l10n_uy_cfe.py @@ -122,7 +122,7 @@ class L10nUyCfe(models.AbstractModel): l10n_uy_dgi_barcode = fields.Text('DGI Barcode', copy=False, readonly=True, groups="base.group_system") l10n_uy_cfe_uuid = fields.Char( 'Clave o UUID del CFE', help="Unique identification per CFE in UCFE. Currently is formed by the concatenation" - " of model name + record id + date", copy=False) + " of model name + record id", copy=False) # TODO este numero debe ser maximo 36 caracteres máximo. esto debemos mejorarlo # Campos compartidos usados desde factura/remitos @@ -1235,6 +1235,10 @@ def check_uy_state(self): elif record.l10n_uy_ucfe_state == '00': raise UserError(_('The operation can not be done. This %s is accepted by DGI.') % record.l10n_latam_document_type_id.name) + def _l10n_uy_get_uuid(self): + self.ensure_one() + return self._name + '-' + str(self.id) + def _l10n_uy_dgi_post(self): """ Implementation via web service of service 310 – Firma y envío de CFE (individual) """ @@ -1244,7 +1248,7 @@ def _l10n_uy_dgi_post(self): CfeXmlOTexto = rec._l10n_uy_create_cfe().get('cfe_str') rec._l10n_uy_vaidate_cfe(CfeXmlOTexto) req_data = { - 'Uuid': self._name + '-' + str(rec.id) + '_' + str(fields.Datetime.now()), # TODO this need to be improve + 'Uuid': self._l10n_uy_get_uuid(), 'TipoCfe': int(rec.l10n_latam_document_type_id.code), 'HoraReq': now.strftime('%H%M%S'), 'FechaReq': now.date().strftime('%Y%m%d'),