Skip to content

Commit

Permalink
[FIX] l10n_br_nfe: nfce test contingency
Browse files Browse the repository at this point in the history
  • Loading branch information
DiegoParadeda committed Dec 12, 2024
1 parent 21eb15f commit d012fd0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
2 changes: 2 additions & 0 deletions l10n_br_account_nfe/models/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,5 +162,7 @@ def _update_nfce_for_offline_contingency(self):
res = super()._update_nfce_for_offline_contingency()
if self.move_ids:
copy_invoice = self.move_ids[0].copy()
copy_invoice.fiscal_document_id.processador_edoc = self.processador_edoc
copy_invoice.fiscal_document_id.nfe_transmission = self.nfe_transmission
copy_invoice.action_post()
return res
21 changes: 19 additions & 2 deletions l10n_br_account_nfe/tests/test_nfce_contingency.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright 2023 KMEE (Felipe Zago Rodrigues <[email protected]>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import fields
from odoo.tests import TransactionCase


Expand Down Expand Up @@ -54,8 +55,24 @@ def prepare_account_move_nfce(self):
"payment_mode_id": payment_mode.id,
"company_id": self.env.ref("base.main_company").id,
"line_ids": [
(0, 0, {"account_id": receivable_account_id.id, "credit": 10}),
(0, 0, {"account_id": payable_account_id.id, "debit": 10}),
(
0,
0,
{
"date_maturity": fields.Date.today(),
"account_id": receivable_account_id.id,
"credit": 10,
},
),
(
0,
0,
{
"date_maturity": fields.Date.today(),
"account_id": payable_account_id.id,
"debit": 10,
},
),
],
}
)
Expand Down
4 changes: 4 additions & 0 deletions l10n_br_nfe/models/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -1528,6 +1528,8 @@ def get_nfce_qrcode(self):
processador = self._edoc_processor()
if self.nfe_transmission == "1":
return processador.monta_qrcode(self.document_key)
if not self.serialize() or not len(self.serialize()):
return

serialized_doc = self.serialize()[0]
xml = processador.assina_raiz(serialized_doc, serialized_doc.infNFe.Id)
Expand All @@ -1536,6 +1538,8 @@ def get_nfce_qrcode(self):
def get_nfce_qrcode_url(self):
if self.document_type != MODELO_FISCAL_NFCE:
return
if self._edoc_processor() is None:
return

return self._edoc_processor().consulta_qrcode_url

Expand Down

0 comments on commit d012fd0

Please sign in to comment.