It seems Odoo guys have yet once more changed methods and classes so, my v10 working examples are messed up in v11...
I need to run a report by code, get the result and save it to an attachment. All by code!
Does anyone know how to do this?
SOLUTION
#run the report and get the pdf (use the reports xml_id and pass record ids into render)
data, data_format = self.env.ref('hr_timesheet.timesheet_report').render([1,2,3])
#save the attachment
att_id = self.env['ir.attachment'].create({
'name': 'My name',
'type': 'binary',
'datas': base64.encodestring(data),
'datas_fname': 'Myname.pdf',
'res_model': 'account.invoice',
'res_id': invoice.id,
'mimetype': 'application/x-pdf'
})
it is all over in the code, why don't you read it ?
F.P. If you don't understand the basic rules of a forum meant for developers to help other developers, I suggest you try Facebook instead.
Thanks a lot for posting the solution, Rui!