From cbd2e6f2a98c8e8c302e7d32603bd90e16faae01 Mon Sep 17 00:00:00 2001 From: Marcel Savegnago Date: Tue, 3 Dec 2024 15:17:22 -0300 Subject: [PATCH] [RFC] l10n_br_nfe: refactor nfce qrcode methods --- l10n_br_nfe/models/document.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/l10n_br_nfe/models/document.py b/l10n_br_nfe/models/document.py index abdfcc7092b0..8abf6d66a408 100644 --- a/l10n_br_nfe/models/document.py +++ b/l10n_br_nfe/models/document.py @@ -1226,14 +1226,23 @@ def _is_nfe_found(c_stat): def _prepare_nfce_send(self): self.ensure_one() - self._prepare_payments_for_nfce() - self.nfe40_infNFeSupl = self.env["l10n_br_fiscal.document.supplement"].create( - { - "nfe40_qrCode": self.get_nfce_qrcode(), - "nfe40_urlChave": self.get_nfce_qrcode_url(), - } + self.nfe40_detPag.filtered(lambda p: p.nfe40_tPag == "99").write( + {"nfe40_xPag": "Outros"} ) + def _document_qrcode(self): + super()._document_qrcode() + + for record in self.filtered(lambda d: d.document_type == MODELO_FISCAL_NFCE): + record.nfe40_infNFeSupl = self.env[ + "l10n_br_fiscal.document.supplement" + ].create( + { + "qrcode": record.get_nfce_qrcode(), + "url_key": record.get_nfce_qrcode_url(), + } + ) + def _eletronic_document_send(self): super()._eletronic_document_send() for record in self.filtered(filter_processador_edoc_nfe): @@ -1528,12 +1537,6 @@ def get_nfce_qrcode_url(self): return self._edoc_processor().consulta_qrcode_url - def _prepare_payments_for_nfce(self): - for rec in self.filtered(lambda d: d.document_type == MODELO_FISCAL_NFCE): - rec.nfe40_detPag.filtered(lambda p: p.nfe40_tPag == "99").write( - {"nfe40_xPag": "Outros"} - ) - def action_danfe_nfce_report(self): return ( self.env["ir.actions.report"]