Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Compute the payslip batch total

By
Koffi KPONOUGLO
on 3/8/16, 1:16 PM 397 views

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.

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)

Koffi KPONOUGLO
on 7/7/16, 1:19 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 3/8/16, 1:16 PM
Seen: 397 times
Last updated: 3/8/16, 1:16 PM