I need to generate a report from 'hr.payslip' but after generated, I got to delete the payslip record. But when I try to delete record before returnin the report, it gives me error because the record no longer exist.
So I think to generate the report and save it in a binary field. I've tried this, with bad results:
def generate_report(self):
# I get this values from another methods,
# I put 1 and 20 just to avoid confution in the question.
run_id = 1
indicador_id = 20
payslip = self.generate_fake_payslip(run_id, self.employee_id.id, indicador_id, self.id)
report = payslip.print_nominee_report()
self.report_file = base64.encodestring(report)
Where generate_fake_payslip()
creates an 'hr.payslip' record and print_nominee_report()
generates the report to download. Instead of returnin the report, I want to save it into report_file binary field. but it gives me:
TypeError: expected bytes-like object, not dict