Skip to Content
Menu
This question has been flagged

I am trying to create a report for payslip batch (hr.payslip.run model) in odoo8. Everything is good. I have my report with the list of employee and their net salaries. I would like to have at the buttom of report, the sum or total of all net salaries. How can i do it?

thanks.

Avatar
Discard
Author

How can i call this function in qweb report to have the payslip batch sum in my report?

def get_payslip_data(self, cr, uid, context=None):

retval = {}

payslip_ids = []

slip_run_ids = context.get('active_ids')

slip_runs = self.pool.get('hr.payslip.run').browse(cr, uid, slip_run_ids, context=context)

payslip_obj = self.pool.get('hr.payslip')

for run in slip_runs:

payslip_ids.extend([x.id for x in run.slip_ids])

payslips = payslip_obj.browse(cr, uid, payslip_ids, context=context)

net_total = 0

net_salary_rule_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'hr_payroll', 'hr_rule_net')[1]

for payslip in payslips:

lines = payslip_obj.get_visible_lines(cr, uid, payslip.id, context=context)

net_salary = sum(x.total for x in lines if x.salary_rule_id.id == net_salary_rule_id)

net_total += net_salary

retval[payslip] = {

'net_salary': net_salary,

}

return (retval, net_total)

Related Posts Replies Views Activity
0
May 15
3663
0
Mar 24
322
0
Jan 24
183
1
Nov 16
2859
2
Apr 24
247