Skip to content
Closed
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
4 changes: 1 addition & 3 deletions l10n_br_fiscal_dfe/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
],
"external_dependencies": {
"python": [
"erpbrasil.edoc>=2.5.2",
"erpbrasil.transmissao>=1.1.0",
"nfelib<=2.0.7",
"nfelib[soap]",
],
},
}
26 changes: 13 additions & 13 deletions l10n_br_fiscal_dfe/models/dfe.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
import logging
import re

from erpbrasil.transmissao import TransmissaoSOAP
from nfelib.nfe.ws.edoc_legacy import NFeAdapter as edoc_nfe
from requests import Session

# from erpbrasil.transmissao import TransmissaoSOAP
# from nfelib.nfe.ws.edoc_legacy import NFeAdapter as edoc_nfe
# from requests import Session
from odoo import _, api, fields, models

from ..tools import utils
Expand Down Expand Up @@ -53,15 +52,16 @@

@api.model
def _get_processor(self):
certificado = self.env.company._get_br_ecertificate()
session = Session()
session.verify = False
return edoc_nfe(
TransmissaoSOAP(certificado, session),
self.company_id.state_id.ibge_code,
versao=self.version,
ambiente=self.environment,
)
raise RuntimeError("TODO adapt for NFe!")

Check warning on line 55 in l10n_br_fiscal_dfe/models/dfe.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_fiscal_dfe/models/dfe.py#L55

Added line #L55 was not covered by tests
# certificado = self.env.company._get_br_ecertificate()
# session = Session()
# session.verify = False
# return edoc_nfe(
# TransmissaoSOAP(certificado, session),
# self.company_id.state_id.ibge_code,
# versao=self.version,
# ambiente=self.environment,
# )

@api.model
def validate_distribution_response(self, result):
Expand Down
2 changes: 1 addition & 1 deletion l10n_br_fiscal_dfe/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from . import test_dfe
# from . import test_dfe
4 changes: 1 addition & 3 deletions l10n_br_mdfe/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@
"auto_install": False,
"external_dependencies": {
"python": [
"nfelib<=2.0.7",
"erpbrasil.transmissao>=1.1.0",
"erpbrasil.edoc>=2.5.2",
"nfelib[soap]",
]
},
}
43 changes: 23 additions & 20 deletions l10n_br_mdfe/models/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@

from erpbrasil.base.fiscal.edoc import ChaveEdoc
from erpbrasil.base.misc import punctuation_rm
from erpbrasil.transmissao import TransmissaoSOAP

# from erpbrasil.transmissao import TransmissaoSOAP
from nfelib.mdfe.bindings.v3_0.mdfe_v3_00 import Mdfe
from nfelib.nfe.ws.edoc_legacy import MDFeAdapter as edoc_mdfe
from requests import Session

# from nfelib.nfe.ws.edoc_legacy import MDFeAdapter as edoc_mdfe
# from requests import Session
from odoo import api, fields

from odoo.addons.l10n_br_fiscal.constants.fiscal import (
Expand Down Expand Up @@ -926,18 +927,18 @@
if self.document_type != MODELO_FISCAL_MDFE:
return super()._edoc_processor()

certificado = self.company_id._get_br_ecertificate()

session = Session()
session.verify = False
# certificado = self.company_id._get_br_ecertificate()
# session = Session()
# session.verify = False

params = {
"transmissao": TransmissaoSOAP(certificado, session),
"uf": self.company_id.state_id.ibge_code,
"versao": self.mdfe_version,
"ambiente": self.mdfe_environment,
}
return edoc_mdfe(**params)
# params = {
# "transmissao": None, # TransmissaoSOAP(certificado, session),
# "uf": self.company_id.state_id.ibge_code,
# "versao": self.mdfe_version,
# "ambiente": self.mdfe_environment,
# }
raise RuntimeError("TODO adapt for MDFe!")

Check warning on line 940 in l10n_br_mdfe/models/document.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_mdfe/models/document.py#L940

Added line #L940 was not covered by tests
# return edoc_mdfe(**params)

def _generate_key(self):
if self.document_type_id.code not in [MODELO_FISCAL_MDFE]:
Expand Down Expand Up @@ -965,10 +966,7 @@
result = super()._document_export()
for record in self.filtered(filtered_processador_edoc_mdfe):
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 @@ -986,8 +984,13 @@
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
4 changes: 1 addition & 3 deletions l10n_br_nfe/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@
"auto_install": False,
"external_dependencies": {
"python": [
"nfelib<=2.0.7",
"erpbrasil.assinatura>=1.7.0",
"erpbrasil.transmissao>=1.1.0",
"nfelib[soap]",
"erpbrasil.edoc>=2.5.2",
"erpbrasil.base>=2.3.0",
"brazilfiscalreport",
Expand Down
Loading