marcydoty / Recursos-NFE-em-Python

http://openobject-brasil.blogspot.com/
Other
73 stars 38 forks source link

Erro ao tentar gerar DANFE #14

Open Marcelo-Kyan opened 8 years ago

Marcelo-Kyan commented 8 years ago

Oi Marcilene,

Ao tentar gerar o DANFE me surgiu a seguinte mensagem:

Traceback (most recent call last): File "./gerar_danfe.py", line 28, in resp = instancia.gerar_danfe(xml,'',emitente,'','kyan',vertical,versao) File "/usr/lib/python2.7/site-packages/python_nfe-3.8-py2.7.egg/nfe/nf_e.py", line 321, in gerar_danfe resp = resp.getElementsByTagName("protNFe")[0] IndexError: list index out of range

Fiz da seguinte forma:

!/usr/bin/env python

from nfe.nf_e import * instancia = nf_e()

Extraindo certificado

certificado = instancia.extrair_certificado_a1("clovis_2015.pfx","xxxxxxxxxx") emitente = certificado['emissor'] cert = certificado['cert'] key = certificado['key']

versao = "3.10" vertical = False

xml = file('nfe.xml','rb').read() resp = instancia.gerar_danfe(xml,'',emitente,'','kyan',vertical,versao) print resp

Marcelo-Kyan commented 8 years ago

Oi Marcilene, Já está enviando NFe, mas estou com vários probleminhas de versão. Acho que deve ter tido algumas implementações para versão 3.10, você ficou de dar uma olhada para mim. Se você achar alguma atualização, por favor me passe, pois acredito que aí deslancha.

Obrigado,

Marcelo-Kyan commented 7 years ago

Oi Marcilene, Nao consigo gerar o danfe. Traceback (most recent call last): File "./gerar_danfe.py", line 42, in retorno = instancia.gerar_danfe(xml,'',emitente,'','kyan',vertical,versao) File "/usr/lib/python2.7/site-packages/nfe/nf_e.py", line 334, in gerar_danfe d.danfe.generate_by(PDFGenerator, filename=danfe_pdf) File "/usr/lib/python2.7/site-packages/geraldo/base.py", line 435, in generate_by return generator.execute() File "/usr/lib/python2.7/site-packages/geraldo/generators/pdf.py", line 100, in execute self.render_bands() File "/usr/lib/python2.7/site-packages/geraldo/generators/base.py", line 548, in render_bands self.start_new_page() File "/usr/lib/python2.7/site-packages/geraldo/generators/base.py", line 436, in start_new_page self.render_page_header() File "/usr/lib/python2.7/site-packages/geraldo/generators/pdf.py", line 234, in render_page_header update_top=False, File "/usr/lib/python2.7/site-packages/geraldo/generators/base.py", line 373, in render_band top_position) File "/usr/lib/python2.7/site-packages/geraldo/generators/base.py", line 222, in render_element para = self.make_paragraph(widget.text, self.make_paragraph_style(band, widget.style)) File "/usr/lib/python2.7/site-packages/geraldo/widgets.py", line 253, in text = property(lambda self: self._text(), _set_text) File "/usr/lib/python2.7/site-packages/geraldo/widgets.py", line 238, in text value = getattr(self, 'action'+self.action)() File "/usr/lib/python2.7/site-packages/geraldo/widgets.py", line 191, in action_value return self.get_object_value(attribute_name=attribute_name) File "/usr/lib/python2.7/site-packages/geraldo/widgets.py", line 160, in get_object_value value = get_attr_value(instance, attribute_name) File "/usr/lib/python2.7/site-packages/geraldo/utils.py", line 98, in get_attr_value raise AttributeNotFound('There is no attribute nor key "%s" in the object "%s"'%(parts[0], repr(obj))) geraldo.exceptions.AttributeNotFound: There is no attribute nor key "NFe" in the object "None"