By: Hilar AK

HR,Unpaid Leaves & Payroll Management in Odoo 10

Functional Odoo 10 Human Resource

Odoo has an Integrated platform with Human Resources and Payroll Engine. Integrating human resources and payroll can reduce paperwork, allows automatic updating and reduce difficulty in providing consolidated reports. Odoo Hr Payroll engine that handles everything required to compute HR salary slips, the taxes to pay, etc. You can manage your company's payroll by using this hr_payroll module. Here We are going to discuss the basic payslip creation and make a salary rule to deduct Unpaid leaves from payslip.

Install Payroll, leaves add-ons. Employees can request leaves according to types specified. Unpaid leave is a type of leave which is in the category of deductions in payroll rules. If Unpaid leaves are approved by manager then while creating payslip of the current employee, it should be deducted. In the form view of payslip, we can see a list which holds the list of worked days, leaves and so on. Follow these steps to deduct Unpaid leaves pay.

1. Create a contract for employee


specifies the Working schedules, type, duration, basic wage, work permit details, scheduled pay and salary structure. Here salary structure is a set of rules which used to compute the payslip of a current employee.

2. Leave Request


From Leaves Menu Employee Gilles Requested 4 days Unpaid Leave and that is in Approved stage

3. Create salary rule to deduct unpaid leaves pay from payslip.


Goto -> payroll -> salaryrules -> create, then add this rule in contract's salary structure
- select a rule category [here we select deductions]
- Give a unique code
- Select conditions based on [none]- Always True
- Computation Based on [code] - Python Code.
- Python Code :-

# Available variables:
# payslip: object containing the pay slips
# employee: hr.employee object
# contract: hr.contract object
# rules: object containing the rules code (previously computed)
# categories: an object containing the computed salary rule categories 
(sum of amount all rules belonging to that category).                 
# worked_days: object containing the computed worked days
# inputs: object containing the computed inputs
# Note: returned value have to be set in the variable 'result'
#Our Computation code to calculate amount In case of 31 days
result =-(contract.wage/31) * worked_days.Unpaid.number_of_days
result = 0

4. Create payslip for the employee

Goto -> payroll -> payslips -> create


Here the Worked days' list is populated with taken leaves
- Compute sheet to see calculations as per salary rules
- You can see the computed Unpaid leaves pay as a deduction on the computer sheet.




Anjila Jolly

28/05/2019 - 4:19AM

I have gotten a lot of information thanks

wow!! want to get best actual payroll management this is best proper system which is very helpful to us payroll always his better services you should keep up your writing Thanks for sharing best way to provide payroll solutions

Kamlesh Vadhiya

21/09/2018 - 12:19AM

very usefull Thanks

Hillar AK

19/10/2017 - 6:25AM

@sanu that should be the error in your code. just clear all unwanted characters in python code form and Have a try. If your rule's code is UNPAID then the code defined in the blog is correct. That is tested. Please have a look at the contract you defined also. If you want to know, how can configure salary rules, check odoo's official documentation or check other blogs related to the salary rule.

Hilar AK

19/09/2017 - 6:32AM

@sanu "Python code wrong " which actually deals on the rule. We are defining the python code here. So while trying to access objects which are not there on payslip will generate Error. So you must check the rule you have created. Don't forget to check the code that you have given on rule and also related configurations done properly. Feel to free to contact our support.

Hello sir. I had followed your steps but unfortunately "Python code wrong " error popped up. i hope you will respond to this reply . I'm using Odoo 10 community


17/03/2019 - 6:57AM

I'm really thankful for the information

I used the same code,but I get the error message ' Wrong python code defined for salary rule Unpaid (UNPAID).'

Very useful information. Thanks for sharing.

Muhammad Kamran

02/11/2017 - 5:44AM

Try This Condition Based on: Python Expression Python Condition: result = worked_days.Unpaid and worked_days.Unpaid.number_of_days or False Amount Type: Python Code Python Code: result = -(contract.wage/30) * worked_days.Unpaid.number_of_day

Leave a comment


Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635


Cybrosys Limited
Alpha House,
100 Borough High Street, London,
SE1 1LB, United Kingdom


Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.


Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message