Skip to Content
Menu
This question has been flagged
1 Reply
1596 Views

Dear all,

anyone knows how to print pdf report from python method? i have this wizard transient model, but when i call print_pdc nothing happens.


class WizardImprimirPDC(models.TransientModel):
_name = 'wizard.imprimir.pdc'
_description = 'Imprimir pla de control'

name = fields.Char(
string="Titulo"
)

desglose = fields.Selection(
string="Nivel de desglose:",
selection=[('1', 'Solo producto principal'),
('2', 'Producto y componentes'),
('3', 'producto, componentes y subcomponentes')])

producto_id = fields.Many2one(
comodel_name="product.product",
string="Producto",
required=True
)

fecha = fields.Date(
string="fecha del informe",
default=fields.Date.today()
)


@api.multi
def print_pdc(self, cr, context=None):
if context is None:
context = {}

data = self.read()[0]
datas = {
'ids': self.producto_id,
'model': 'wizard.imprimir.pdc',
'form': data
}
res = {
'type': 'ir.actions.report',
'report_name': 'reports/nd_calidad_pdc_es.odt',
'datas': datas
}

return res
Avatar
Discard
Author Best Answer

in the end i returned this, instead of the previous dictionary, and now it works with py3o

@api.multi
def print_pdc_report(self):
return self.env.ref('nd_calidad_es.%s'%self.formato).report_action(self)

Avatar
Discard
Related Posts Replies Views Activity
1
Sep 24
322
1
Jul 24
273
1
May 24
1628
1
May 24
645
0
Mar 24
4