Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions l10n_br_mdfe/models/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -977,8 +977,14 @@ def _document_export(self, pretty_print=True):
document_id=self,
)
record.authorization_event_id = event_id
xml_assinado = processador.assina_raiz(edoc, edoc.infMDFe.Id)
self._validate_xml(xml_assinado)
signed_xml = edoc.sign_xml(
xml_file,
self.company_id.certificate.file,
self.company_id.certificate.password,
edoc.infMDFe.Id,
)
self._validate_xml(signed_xml)

return result

def _validate_xml(self, xml_file):
Expand Down
14 changes: 8 additions & 6 deletions l10n_br_nfe/models/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -956,10 +956,7 @@ def _document_export(self, pretty_print=True):
result = super()._document_export()
for record in self.filtered(filter_processador_edoc_nfe):
edoc = record.serialize()[0]
processador = record._edoc_processor()
xml_file = processador.render_edoc_xsdata(edoc, pretty_print=pretty_print)[
0
]
xml_file = edoc.to_xml()
# Delete previous authorization events in draft
if (
record.authorization_event_id
Expand All @@ -977,8 +974,13 @@ def _document_export(self, pretty_print=True):
document_id=self,
)
record.authorization_event_id = event_id
xml_assinado = processador.assina_raiz(edoc, edoc.infNFe.Id)
self._validate_xml(xml_assinado)
signed_xml = edoc.sign_xml(
xml_file,
self.company_id.certificate.file,
self.company_id.certificate.password,
edoc.infNFe.Id,
)
self._validate_xml(signed_xml)
return result

def _nfe_update_status_and_save_data(self, process):
Expand Down