跳至内容
菜单
此问题已终结
1 回复
2667 查看

I'm developing a module to calculate salaries.

Once all salaries are calculated, in 'hr.contract' form, I will have an option to print a report.

This report has to be the same report that I can print in 'hr.payslip' form.

So, the question is if it's possible to do this. I've tried but with bad results.

I've tried this:


class HrContract(models.Model):
    _inherit = 'hr.contract'

    def print_nominee_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

        # this method generate a payslip from which I want the report.
        payslip = self.generate_payslip(run_id, self.employee_id.id, indicador_id, self.id) 
        ids = [payslip.id]
        data = {
            'ids': ids,
            'model': 'hr.payslip',
            'form': self.env['hr.payslip'].search([('id', '=', payslip.id)])
        }
        return self.env.ref('hr_payroll.action_report_payslip').report_action(self, data=data)



but the result is an empty PDF.

形象
丢弃
最佳答案

Hi  Sergio,

Can you please try with passing payslip ID instead of self?

return self.env.ref('hr_payroll.action_report_payslip').report_action(payslip.id, data=data)

Thank you!

Regards,




Email:      odoo@aktivsoftware.com  

Skype: kalpeshmaheshwari

    

形象
丢弃
相关帖文 回复 查看 活动
1
8月 25
568
1
4月 25
1589
1
9月 24
2267
1
7月 24
2030
1
5月 24
4432