Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

i need to make new rules with python code to compute for OVERTIME?

Subscribe

Get notified when there's activity on this post

This question has been flagged
payrollsalary_rulespayslipsodoo16featurespython3.10
3 Replies
6037 Views
Avatar
Zahra Naveed

Overtime is usually double the per hour rate of any employee and its calculated in hours.
means, Contract Wage (Fix) / total number of days in a month = Per Day Wage
Per day wage / Total number of Working Hours in a day = Per hour Contract Wage

Overtime = Per hour Contract Wage x 2

so what will be the code?
thanks in advance

0
Avatar
Discard
Avatar
Mubeen Sulehri
Best Answer

I am also working on overtime salary rule. Can you plz share the python code 


0
Avatar
Discard
Zahra Naveed
Author

regular_hours_per_month = 23 * 8
regular_hourly_rate = contract.wage / regular_hours_per_month

result = 0
for line in payslip.worked_days_line_ids:
if line.code != 'LEAVE90':
if line.number_of_hours <= regular_hours_per_month:
result += line.number_of_hours * regular_hourly_rate
else:
regular_payment = regular_hours_per_month * regular_hourly_rate
extra_hours = line.number_of_hours - regular_hours_per_month
extra_payment = extra_hours * (regular_hourly_rate * 2)
result += regular_payment + extra_payment

result = result

hope it will help you.

Avatar
Cybrosys Techno Solutions Pvt.Ltd
Best Answer

Hi

Create a new rule named "OverTime" in the payslip. In the computation part, select "Amount Type" as "Python code" and use the following code:
result = contract_wage * 2 / (total_number_of_days_in_a_month * total_number_of_working_hours_in_a_day)
Please ensure that you replace "total_number_of_days_in_a_month" with the actual total number of days in a month and "total_number_of_working_hours_in_a_day" with the total number of working hours in a day as per your specific context.


Hope it helps

0
Avatar
Discard
Shakeel Ahmad

Standard working hours=208
worked hours(Attendance)=221
Overtime=221-208=13
Attendance pora ho toh 1500 basic ana chahiye aur jo overtime ho wo khud he 13hr show kr kay 8 sey multiply krey
Thank You

Zahra Naveed
Author

Thanks @Cybrosys Techno Solutions Pvt.Ltd for your answer i have solved this problem .In your answer after defining the new rule ''overtime" it will not take the overtime hours own its own. so i had to use the bit different approch before the calculation.

Kenny Muhire

@zahra naveed , what's the approach that you used ?

Zahra Naveed
Author

@kenny Hi , i know it might be too late but if you still want this is what i did
hour_per_day = 8
days_in_month = 30
regular_hours_per_month = days_in_month * hour_per_day
regular_hourly_rate = contract.wage / regular_hours_per_month

result = 0
for line in payslip.worked_days_line_ids:
if line.code not in ['LEAVE90', 'OVERTIME']:
if line.number_of_hours <= regular_hours_per_month:
result += line.number_of_hours * regular_hourly_rate
else:
regular_payment = regular_hours_per_month * regular_hourly_rate
result += regular_payment

result = result

Avatar
Dan Vlas
Best Answer

Try to create a new rule in the hr.payslip model - where define a new field called overtime as a float type, and we use the @api.depends decorator to compute its value based on the worked_hours and the employee's contract information.

0
Avatar
Discard
Zahra Naveed
Author

can you please write the code .

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Related Posts Replies Views Activity
How to get total number_of_day of GLOBAL in WORKED DAYS table
payroll salary_rules odoo16features
Avatar
0
Nov 23
2732
Calculate payslip after deducting unpaid leaves
payroll salary_rules leavemanagement payslips
Avatar
Avatar
1
Apr 17
5816
Employees cannot print their payslips
payroll payslip payslips access rights odoo16features
Avatar
Avatar
1
May 24
2334
How Can I write rules for Salary Solved
hr python payroll salary_rules payslips
Avatar
Avatar
1
Sep 23
14322
How i can change the attendance app value in payroll app in pay slip odoo16
payroll attendance overtime payslips odoo16features
Avatar
Avatar
1
Jul 23
3242
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now