Skip to content

Commit

Permalink
[ADD] l10n_uy_edi: CFE UFCE Uuid
Browse files Browse the repository at this point in the history
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.

closes #139

Related: ingadhoc/odoo-saas-adhoc#533
Signed-off-by: Katherine Zaoral <[email protected]>
  • Loading branch information
zaoral committed Sep 2, 2023
1 parent 9e9a8a6 commit 21e86a0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions l10n_uy_edi/models/l10n_uy_cfe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) """

Expand All @@ -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'),
Expand Down

0 comments on commit 21e86a0

Please sign in to comment.