Commit 71fc46db by Juan

impresion e identificacion de comprobante para pagina

1 parent 06d0714b
...@@ -7,3 +7,4 @@ from . import dias ...@@ -7,3 +7,4 @@ from . import dias
from . import solicitudes from . import solicitudes
from . import mensajes from . import mensajes
from . import no_transporta from . import no_transporta
from . import comprobante
\ No newline at end of file \ No newline at end of file
# -*- coding: utf-8 -*-
from odoo import models, fields, api, exceptions
from odoo.exceptions import UserError, ValidationError, Warning, RedirectWarning
import base64
class asw_comprobante(models.Model):
_inherit = 'asw.comprobante'
_order = 'id desc'
tipo_comprobante_lappa = fields.Char(string='Tipo de comprobante',
readonly=True, compute="_tipo_comprobante_lappa")
@api.depends('tipo_comprobante_lappa')
def _tipo_comprobante_lappa(self):
adap = {"fac":"Factura","rec":"Recivo"}
for rec in self:
tal = rec.comp_talonario.tal_menu
if tal in ["fac","rec"]:
tipo = adap[tal]
else:
tipo = "otro"
rec.tipo_comprobante_lappa = tipo
def DescargarPDF(self,val):
if len(self) != 1:
raise Warning("Seleccione un regisrto")
print(val)
rec = self.sudo(8)# usuario que pueda imprimir bien
result = rec.imprimir()
report_action = rec.env[result['type']]._get_report_from_name(result['report_name'])
pdf = report_action.render_aeroo([rec.id], {'context': rec.env.context})
nombre_pdf = pdf[2].replace(' ', '').replace(".pdf.pdf",".pdf")
contenido = base64.b64encode(pdf[0])
return({"filename":nombre_pdf,"file":contenido})
\ No newline at end of file \ No newline at end of file
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!