Skip to Content
Menu
This question has been flagged

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)

else:

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.




Avatar
Discard
Related Posts Replies Views Activity
1
Jun 19
2839
1
Jul 24
186
2
Feb 19
2885
1
Jan 19
2729
0
Mar 15
2600