Ir al contenido
Menú
Se marcó esta pregunta

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
Descartar
Autor

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)

Publicaciones relacionadas Respuestas Vistas Actividad
0
may 15
4506
1
feb 25
1220
0
ene 24
938
1
nov 16
3547
2
abr 24
1304