HR-Unpaid-Leaves-payroll-Management-in-Odoo-10.png
Blogger_636317075652283750.jpg
By: Hilar AK

HR,Unpaid Leaves & Payroll Management in Odoo 10

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

http/blog/Uploads/BlogImage/HR-Unpaid-Leaves-payroll-Management-in-Odoo-10.png

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

http/blog/Uploads/BlogImage/HR-Unpaid-Leaves-payroll-Management-in-Odoo-10.png

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.

http/blog/Uploads/BlogImage/HR-Unpaid-Leaves-payroll-Management-in-Odoo-10.png

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
try:
result =-(contract.wage/31) * worked_days.Unpaid.number_of_days
except:
result = 0


4. Create payslip for the employee

Goto -> payroll -> payslips -> create

http/blog/Uploads/BlogImage/HR-Unpaid-Leaves-payroll-Management-in-Odoo-10.png

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 computed sheet.

http/blog/Uploads/BlogImage/HR-Unpaid-Leaves-payroll-Management-in-Odoo-10.png




Comments

5

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.


sanu

19/09/2017 - 1:51AM

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


Jay

16/10/2017 - 8:46AM

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


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