Please help to get a python function to attach Qweb Report (PDF file) in a binary field
v15c
report_file = fields.Many2one('ir.attachment', string='PDF')
def generate_report_file(self):
report_template_id = self.env.ref('id_card_by_fas.id_card_template_report').render_qweb_pdf(self.id)
data_record = base64.b64encode(report_template_id[0])
ir_values = {
'name': "ID Card",
'type': 'binary',
'datas': data_record,
'store_fname': data_record,
'mimetype': 'application/x-pdf',
}
data_id = self.env['ir.attachment'].create(ir_values)
self.report_file = data_id.id
return True
Tried above method, but showing the error "AttributeError: 'ir.actions.report' object has no attribute 'render_qweb_pdf'"
in odoo 15 method is: _render_qweb_pdf