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

salary rule for unpaid leaves based on number of days of months

Subscribe

Get notified when there's activity on this post

This question has been flagged
python2.7odooodoo10
2 Replies
9712 Views
Avatar
SSS

Hello,

I am trying to deduct salary for unpaid leaves based on number of days of month. 

​In hr.payslip following line is added.

day =  datetime.strptime(date_to,"%Y-%m-%d").day

res['value'].update({
'day': day,
})

'day' give me last day of month. For salary rule I have try:

result=(contract.wage/payslip.day)*worked_days.Unpaid.number_of_days

But Following error occur:

res['value'].update({
TypeError: list indices must be integers, not str 

I understand error, also try for integer list but nothing will happen.Any suggestion

For above I refer following link:

https://www.odoo.com/forum/help-1/question/unpaid-leaves-deduction-not-working-16131

​and also I want to define organisation holiday. For organisation holiday salary not deduct for that I want add salary rule.

1
Avatar
Discard
Avatar
Hilar Andikkadavath
Best Answer

The calculations you defined here are entirely wrong. How can u make sure your to-date in payslip is the last day of the month. One more thing to be checked here is if you put the salary for two months then which day you gonna take. 

In case of a payslip period in a single month.

Total days in a month can be calculated using this formula.

import calendar
day_from = fields.Date.from_string(from_date) #TO date object
calendar.monthrange(day_from.year, day_from.month)[1] # will be 31 | 30, For FEB 28|29
Payslip period for more than a month.
for this case I can suggest you two logics. 
1. You can predefine the the total days like 30 | 31.
2. result will be the sum of total of all months.
eg: result = result + (contract.wage/payslip.day of nth month)*worked_days.Unpaid.number_of_days
To do that, you can either split the Worked day lines according to the months or you can hard code in salary rules.
4
Avatar
Discard
SSS
Author

I want payslip only for one month not for more than month that's the reason I am consider to_date as a last date of month. But the problem is that when adding result=(contract.wage/payslip.day)*worked_days.Unpaid.number_of_days into the salary rule. gives me error "float division by zero" means payslip.day not contain 30 | 31. I dont understand why this happen. I am also tried your suggestion for one month payslip but not work.

Hilar Andikkadavath

Your payslip.day is zero, that's why. Properly update value to payslip.day

Hilar Andikkadavath

I don't know how you are updating payslip.day, but I can suggest you keep that as a computed field. I think you are updating the value wrongly.

SSS
Author

Firstly i inherit hr.payslip with get_worked_day_lines method in that I have try this code

day_from = fields.Date.from_string(date_from)

day = calendar.monthrange(day_from.year, day_from.month)[1]

res1.append(day)

return res1[0]

I think I am inheriting wrong method that's the reason payslip.day

SSS
Author

I think I am inheriting wrong method that's the reason payslip.day contain zero.

Hilar Andikkadavath

okay, make your field as computed and in the computed function, do the tweak

SSS
Author

Thanks @Hilar AK for your time and suggestion. My problem is solved.

Avatar
Niyas Raphy (Walnut Software Solutions)
Best Answer

Hi,

Please check whether this helps,

1. Deduct Employee Salary When Taking Leaves In Odoo Payroll

2. How To Set Public Holidays/Global Leaves In Odoo

Thanks

2
Avatar
Discard
SSS
Author

Thanks @Niyas Paphy for your time and suggestion.links given by you also helpfull.

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 can i call my method after create new object in odoo 10?
python2.7 odoo odoo10
Avatar
Avatar
Avatar
2
Aug 22
12676
[SOLVED] How to Hide or Delete Trash Icon in One2many field Solved
python python2.7 odoo odoo10
Avatar
Avatar
2
Aug 25
13195
Filter value 2 field of Many2one
python python2.7 odoo odoo10
Avatar
Avatar
Avatar
5
Sep 20
7165
Filter field domain one2many to many2one Solved
python python2.7 odoo odoo10
Avatar
Avatar
1
Dec 19
10509
How to open direct list view instead of select "Search More.." in Many2one field for Odoo10
python2.7 many2one_list odoo odoo10
Avatar
Avatar
1
Feb 24
7371
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