Help

Welcome!

This community is for professionals and enthusiasts of our products and services.
Share and discuss the best content and new marketing ideas, build your professional profile and become a better marketer together.

0

Overtime Computation per Overtime Code

0
3
2,365

Using this module we purchased: https://apps.odoo.com/apps/modules/12.0/to_hr_overtime_payroll/

I want to create a different salary rule with different computation base on Overtime HOUR TOTAL for each Overtime Type group by type. How would I achieve it using python code?

For Example I have OTREG and OTSUN

CODE : OTHOUR : SALARY RULE : PYTHON CODE

OTREG0006 : 05 : REGULAR OVERTIME : ????

OTREG0617 : 05 : REGULAR OVERTIME : ????

OTSUN0006 : 08 : SUNDAY OVERTIME : ????

OTSUN0617 : 04 : SUNDAY OVERTIME : ????

Avatar
Discard
3 Answers
0
Best Answer

You can filter the ot lines by the code of the desired rate. For example, below is the code for the OTREG0006

amount = 0.0
for line in payslip.payslip_ot_line_ids.filtered(lambda l: l.overtime_rule_id.code == 'OTREG0006'):
	amount += 20 * line.number_of_hours * line.rate / 100.0
result = amount
Comment Share
Avatar
Discard
0
Best Answer

actually, the computation is right, but i want to separate all each overtime rate into different salary rule computation for intensive report purpose.

Avatar
Renato Lopez Jr.
Comment Share
Avatar
Renato Lopez Jr.
Avatar
Discard
0
Best Answer

There is a rule named "Overtime Allowance Amount" added by this module, in which the computation is as follow

# find total working hours
total_hours = sum(line.number_of_hours for line in payslip.worked_days_line_ids)

# cost per hour is calculated base on contract's wage and above found total hours
hour_cost = total_hours and contract.wage / total_hours or 0.0

# start calculating overtime cost
amount = 0.0
for line in payslip.payslip_ot_line_ids:
	if payslip.contract_id:
		amount += hour_cost * line.number_of_hours * line.rate / 100
result = amount


As for your case, I will need more information on how you caculate your overtime. I.e.: base amount, rate for each type of overtime against the base.

I assume that
  • base amount: $20/hour
  • rate of the OTREG0006: 150%
  • rate of the OTREG0617: 150%
  • rate of the OTSUN0006: 200%
  • rate of the OTSUN0617: 200%
  • the employee has 10 overtime hours against the OTREG0006 and 5 overtime hours against the OTSUN0006 and 7 overtime hours against the OTSUN0617 and

The python code below could give you the result as 780
amount = 0.0
for line in payslip.payslip_ot_line_ids:
	amount += 20 * line.number_of_hours * line.rate / 100.0
# after the loop, the cummulative amount should be 780.0
result = amount
Comment Share
Avatar
Discard

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!

Q&A Forum Regulations

Forum Regulations

By using the FAQ Forum on ERPOnline.vn website, you unconditionally agree to the following terms:

    1. Q&A Forum is a discussion environment to support each other in Odoo/ERPOnline implementation, in the spirit of "community support community", with internet address at: https://www.erponline.vn/forum/hoi-dap-7

    2. You are thoroughly responsible for the content submitted by you.

    3. DO NOT use the Q&A Forum for any activities that violate Vietnamese law and International Conventions to which Vietnam is a participant.

    4. DO NOT post content that is offensive, defamatory, or discredits other individuals or legal entities.

    5. DO NOT post advertisements or advertising content.

    6. DO NOT post content that is not related to management software and ERP in general as well as OpenERP and ERPOnline.vn in particular.

    7. DO NOT post copyrighted content or content, materials, products protected by Intellectual Property law without the written consent of the author.

    8. DO NOT embed images from other websites.

    9. You agree that all options, solutions, answers in the Q&A section on ERPOnline.vn website are for reference only. ERPOnline.vn website will not be liable if you have any damage when applying the plans given in the Q&A section on ERPOnline.vn website.

These terms and conditions may be amended to suit reality at any time without prior notice.