From 196919e032dbd30e2daaf9925c04b8e8e6c815df Mon Sep 17 00:00:00 2001 From: Maximiliano Mezzavilla Date: Tue, 10 Oct 2023 14:28:57 -0300 Subject: [PATCH] [ADD] l10n_uy_edi: Nuevas disposiciones de DGI Task: 33669 --- l10n_uy_edi/models/account_move.py | 15 ++++++++++----- l10n_uy_edi/models/l10n_uy_cfe.py | 3 ++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/l10n_uy_edi/models/account_move.py b/l10n_uy_edi/models/account_move.py index 33e7a9ab..f0fb8d2e 100644 --- a/l10n_uy_edi/models/account_move.py +++ b/l10n_uy_edi/models/account_move.py @@ -90,15 +90,20 @@ def _amount_total_company_currency(self): # Helpers def _uy_found_related_cfe(self): - """ return the related/origin cfe of a given cfe """ + """ return the related/origin cfe of a given cfe + Segun cambios en formatos de CFE v.24 + los cfe relacionados deben estar aceptados por DGI + """ # next version review to merge this with l10n_ar_edi _found_related_invoice method self.ensure_one() + res = self.env['account.move'] if self.l10n_latam_document_type_id.internal_type == 'credit_note': - return self.reversed_entry_id + res = self.reversed_entry_id elif self.l10n_latam_document_type_id.internal_type == 'debit_note': - return self.debit_origin_id - else: - return self.browse() + res = self.debit_origin_id + if res and res.l10n_uy_cfe_state != 'accepted': + raise UserError(_('El comprobante que estas anexando como referencia no es un comprobante valido para DGI(aceptado)')) + return res def _is_uy_cfe(self): return bool(self.journal_id.l10n_latam_use_documents and self.company_id.country_code == "UY" diff --git a/l10n_uy_edi/models/l10n_uy_cfe.py b/l10n_uy_edi/models/l10n_uy_cfe.py index af05726b..086adf62 100644 --- a/l10n_uy_edi/models/l10n_uy_cfe.py +++ b/l10n_uy_edi/models/l10n_uy_cfe.py @@ -1146,7 +1146,8 @@ def _l10n_uy_get_cfe_referencia(self): 'Serie': document_number[0], 'NroCFERef': document_number[1], # 'FechaCFEref': 2015-01-31, TODO inform? - }) + }) + return res def action_l10n_uy_get_pdf(self):