Hi,
The following code throws "Missing Record" error and I can't figure out how to fix it.
def action_send_invoice(self):
report_template_id = self.env.ref('test-module.report_crm_invoice')._render_qweb_pdf(self.id)
data_record = base64.b64encode(report_template_id[0])
ir_values = {
'name': "Invoice",
'type': 'binary',
'datas': data_record,
'store_fname': data_record,
'mimetype': 'application/x-pdf',
}
data_id = self.env['ir.attachment'].create(ir_values)
pdf_file = data_id.id
invoice_vals = {
'lead_id': self.id,
'pdf': pdf_file,
}
invoice = self.env['custom-module.invoice'].create(invoice_vals)
I am trying to generate a PDF using my existing Report and storing it inside a new Invoice object. I tried to follow the example here: https://www.odoo.com/tr_TR/forum/yardim-1/attach-qweb-report-pdf-file-in-a-binary-field-201228
However, the code doesn't work for some reason and throws the Missing Record error saying:
Record does not exist or has been deleted.
(Record: ir.actions.report(6,), User: 2)