Odoo Help


call function on report

on 3/4/16, 12:27 PM 474 views

Hello everybody.

i have this function 


 def get_salarial_data(self, cr, uid, payslip, yearly=False, context=None):

retval = {}

keys = ['gross', 'salarial_costs', 'patronal_costs',

'net_salary', 'benefits_in_kind', 'worked_hours', 'worked_days']

lines = payslip.get_visible_lines(context=context)

gross = sum(x.total for x in lines if x.sequence in [1999])

salarial_costs = sum(x.total for x in lines if x.sequence in [2040])

patronal_costs = sum(x.total for x in lines if x.sequence in [2041])

net_salary = sum(x.total for x in lines if x.sequence in [5000])

benefits_in_kind = sum(x.total for x in lines if x.sequence in [1009])

# For now, it's 160, except the 1st month, when it's prorata.

days_in_service = (datetime.strptime(payslip.date_to, '%Y-%m-%d') \

- datetime.strptime(payslip.employee_id.start_date, '%Y-%m-%d')).days

days_in_month = (datetime.strptime(payslip.date_to, '%Y-%m-%d') \

- datetime.strptime(payslip.date_from, '%Y-%m-%d')).days

worked_hours = int(160 * min(1, float(days_in_service) / days_in_month))

worked_hours = sum([x.number_of_hours for x in payslip.worked_days_line_ids])

worked_days = sum([x.number_of_days for x in payslip.worked_days_line_ids])

if not yearly:

retval['lines'] = lines

for key in keys:

retval[key] = locals().get(key)


for key in keys:

retval[key + '_year'] = locals().get(key)

return retval

how can i call this fonction in my payslip report template to have the values of salarial_costs, patronal_costs, net_salary, worked_hours or worked_days.

thanks in advance.

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 platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 3/4/16, 12:27 PM
Seen: 474 times
Last updated: 3/4/16, 12:27 PM