I am trying to add a Qweb Report (PDF file) to a binary field. I used the below code but I am getting the error message, "AttributeError: 'ir.actions.report' object has no attribute 'render_qweb_pdf". I am using odoo version 15.
report_file = fields.Many2one('ir.attachment', string='PDF')
def report_file_generate(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