Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
I wonder how can I prevent HR Managers from approving their own leave requests?
HR Managers requests must be approved by one of their colleagues.
However, I also must be able to tell openERP that certain managers are allowed to approve their own requests.
per default, any user who belong to group HR Officer will be able to approve leave requests for anybody; this is done by setting a group in the corresponding workflow transition (from state confirm to state validate in hr.wkf.holidays).
What we will do to achieve our goal is :
- creating a new group;
- creating a function to check if the officer is about to validate is own request.
- changing the condition to validate the transition.
1/ Create the group :
- Name : Can't Approve own leaves (or whatever you need)
- Application : HR
2/ create the function :
- add the following code to the hr_holidays.py file
def is_officer_employee(self, cr, uid, ids, *args): for leave in self.browse(cr, uid, ids): if uid==leave.employee_id.user_id.id: return True else: return FalseThis code has to be in the class hr_holidays
- delete the hr_holidays.pyc file
- restart your server with option --update=hr_holidays
3/ Modify the workflow
- The easiest way to do it is to go in SettingsÂ \ Configuration \ Worflows \ Workflows and edit hr.wkf.holidays in diagram view
- double clic on the transition
- change the condition from "not double_validation" to "not double_validation and not is_officer_employee()"
- change the Group Required from "Human Resources / Officer" to "Human Resources / Can't Approve own leaves"
- don't use admin user since it has special rights
- don't forget to add your user to both groups Officer and Can't Approve own leaves.
PS: please vote if you find it helpful.
About This Community
This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 8/6/13, 11:50 AM|
|Seen: 3673 times|
|Last updated: 3/16/15, 8:10 AM|