I made a function in 'hr.contract' that generate a payslip. But this payslip is used to simulate and calculate some salaries, so after create the payslip I must delete it.
Also, I made a function to print the payslip report, from the contract form. The problem is, when I click "print" button I create the payslip and return its report, but then I can't figure out a way to delete the payslip created.
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_nominee(run_id, self.employee_id.id, indicador_id, self.id)
report = payslip.print_nominee_report()
return report
I can't do stuff after the return, so any ideas?
Hello Sergio,
In Python/all programming languages when you return, that is the end of that statement.
What happens when you delete the payslip before the return line? As you are returning a report in a variable and should have no need for the payslip anymore?
Thanks,
Hello Jack, thanks for your response. When I call generate_fake_nominee() it creates a payslip so it is saved on DB. If I delete the payslip before return, I get:
"Error to render compiling AST
MissingError: ('Record doesn't exist or has been deleted.\n\n(Records: hr.payslip(215,), User: 2)', None)
Template: 1179
Path: /templates/t/t/t/t/div/h5/span
Node: <span t-field="o.name"/>"
Could you archive the template instead of deleting?
Payslip* not template