PDF Carta porte V3.1
PARTE 2
Actualizar QR del PDF de carta porte
Hola @agb80 retomando el diseño de solución para generar el QR de carta porte
Las modificaciones que realice fueron las siguientes
# -*- coding: utf-8 -*-
from openerp.report import report_sxw
class Parser(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(Parser, self).__init__(cr, uid, name, context)
self.localcontext.update(
{
"qrcode_string": self._qrcode_string,
}
)
@staticmethod
def _qrcode_string(uuid, re, rr, tt, fe):
"""Funtion that creates string that will be used to create the CFDI QR Code
@param uuid: document uuid
@param re: emitter document TIN
@param rr: receiver document TIN
@param tt: documen total
@param fe: document cfdi stamp code
"""
if fe:
sello = fe[-8: len(fe)]
param_dict = {
"?id=": "uuid",
"&re=": "re",
"&rr=": "rr",
"&tt=": "tt",
"&fe=": sello,
}
cadena = "https://verificacfdi.facturaelectronica.sat.gob.mx/default.aspx"
for key, value in param_dict:
cadena += "&" + key + ":" + value
El contenido de la imagen qr en el reporte es lo siguiente:
image: barcode(qrcode_string(o.cfdi_folio_fiscal or "N/A", o.company_id.partner_id.vat_split, o.commercial_partner_id.vat_split, str(o.total), o.cfdi_id.sello or ""), 'qrcode', options=dict(version=10, eclevel='M'), scale=1.4)
Y me marca el siguiente error
> Traceback (most recent call last):
> File "/home/openpyme/Documentos/locales/demo/parts/server/openerp/http.py", line 557, in _handle_exception
> return super(JsonRequest, self)._handle_exception(exception)
> File "/home/openpyme/Documentos/locales/demo/parts/server/openerp/http.py", line 594, in dispatch
> result = self._call_function(**self.params)
> File "/home/openpyme/Documentos/locales/demo/parts/server/openerp/http.py", line 330, in _call_function
> return checked_call(self.db, *args, **kwargs)
> File "/home/openpyme/Documentos/locales/demo/parts/server/openerp/service/model.py", line 113, in wrapper
> return f(dbname, *args, **kwargs)
> File "/home/openpyme/Documentos/locales/demo/parts/server/openerp/http.py", line 327, in checked_call
> return self.endpoint(*a, **kw)
> File "/home/openpyme/Documentos/locales/demo/parts/server/openerp/http.py", line 823, in __call__
> return self.method(*args, **kw)
> File "/home/openpyme/Documentos/locales/demo/parts/server/openerp/http.py", line 423, in response_wrap
> response = f(*args, **kw)
> File "/home/openpyme/Documentos/locales/demo/parts/server/addons/web/controllers/main.py", line 950, in call_button
> action = self._call_kw(model, method, args, {})
> File "/home/openpyme/Documentos/locales/demo/parts/server/addons/web/controllers/main.py", line 938, in _call_kw
> return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
> File "/home/openpyme/Documentos/locales/demo/parts/server/openerp/api.py", line 268, in wrapper
> return old_api(self, *args, **kwargs)
> File "/home/openpyme/Documentos/locales/demo/parts/server/openerp/api.py", line 399, in old_api
> result = method(recs, *args, **kwargs)
> File "/home/openpyme/Documentos/locales/demo/parts/facturacion/l10n_mx_ir_attachment_facturae/models/ir_attachment_facturae.py", line 588, in action_create_pdf
> record.id, self.config_id.template_pdf_sign, model=record._name
> File "/home/openpyme/Documentos/locales/demo/parts/server/openerp/api.py", line 266, in wrapper
> return new_api(self, *args, **kwargs)
> File "/home/openpyme/Documentos/locales/demo/parts/facturacion/l10n_mx_ir_attachment_facturae/models/ir_attachment_facturae.py", line 859, in create_report
> self.env.cr, self.env.uid, [attach_id], report_name, {"model": model}
> File "/home/openpyme/Documentos/locales/demo/parts/server/openerp/report/__init__.py", line 40, in render_report
> return registry['ir.actions.report.xml'].render_report(cr, uid, ids, name, data, context)
> File "/home/openpyme/Documentos/locales/demo/parts/server/openerp/api.py", line 268, in wrapper
> return old_api(self, *args, **kwargs)
> File "/home/openpyme/Documentos/locales/demo/parts/server/openerp/addons/base/ir/ir_actions.py", line 160, in render_report
> return new_report.create(cr, uid, res_ids, data, context)
> File "/home/openpyme/Documentos/locales/demo/parts/aeroo_reports/report_aeroo/report_aeroo.py", line 823, in create
> res = fnct(cr, uid, ids, data, report_xml, context)
> File "/home/openpyme/Documentos/locales/demo/parts/aeroo_reports/report_aeroo/report_aeroo.py", line 726, in create_source_pdf
> return self.create_single_pdf(cr, uid, ids, data, report_xml, context)
> File "/home/openpyme/Documentos/locales/demo/parts/aeroo_reports/report_aeroo/report_aeroo.py", line 632, in create_single_pdf
> return self.create_aeroo_report(cr, uid, ids, data, report_xml, context=context, output=output)
> File "/home/openpyme/Documentos/locales/demo/parts/aeroo_reports/report_aeroo/report_aeroo.py", line 589, in create_aeroo_report
> self._raise_exception(e, print_id)
> File "/home/openpyme/Documentos/locales/demo/parts/aeroo_reports/report_aeroo/report_aeroo.py", line 455, in _raise_exception
> raise Exception(_("Aeroo Reports: Error while generating the report."), e, str(e), _("For more reference inspect error logs."))
> Exception: (u'Aeroo Reports: Error while generating the report.', ValueError('too many values to unpack',), 'too many values to unpack', u'For more reference inspect error logs.')
Si me apoyas con las observaciones o el camino que debo seguir para este diseño de solución.
Quedo al pendiente