Hello I am making a report and I need send some variables tat I have created while I was calculating everything. He is my code.
_name = 'model.wizard'
product_id = fields.Many2one('product.product', string='Producto', widget='selection', required=True)
@api.multi
def imprimir(self):
self.ventas = self.env['pos.order.line'].search([('product_id', '=', self.product_id.id)])
self.costos = self.env['product.price.history'].search([('product_template_id', '=', self.product_id.product_tmpl_id.id)])
record = self.read()
datas = {
'model' : 'model.wizard',
'ids' : self.ids,
'form' : record,
}
print(datas)
return{
'type' : 'ir.actions.report.xml',
'report_name' : 'model.utilities',
'datas' : datas,
'nodestroy' : True,
}
def print_report(self, cr, uid, ids,context=None):
record = self.read(cr, uid, ids[0], context=context)
print(record)
datas = {
'model' : 'product.produdct',
'ids' : ids,
'form' : record
}
return{
'type' : 'ir.actions.report.xml',
'report_name' : 'model.utilities',
'datas' : datas,
'nodestroy' : True
}
report.xml:
<openerp>
<data>
<report
id="report_sale_utilities"
model="model.wizard"
string="Reporte de utilidad"
name="model.utilities"
file="model.utilities"
report_type="qweb-pdf"
menu="False"/>
<template id="utilities">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="doc">
<t t-call="report.external_layout">
<div class="page">
<p><h2>Producto:</h2> <span t-field="doc.product_id.name"/></p>
<separator/>
</div>
</t>
</t>
</t>
</template>
</data>
</openerp>