-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX]hr_timesheet_sheet_validators move validation to employee side
- Loading branch information
1 parent
71352f3
commit 865e6b6
Showing
4 changed files
with
51 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from . import hr_timesheet_sheet | ||
from . import hr_employee |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from odoo import api, models | ||
|
||
|
||
class HrEmployee(models.Model): | ||
_inherit = "hr.employee" | ||
|
||
@api.multi | ||
def get_validator_user_ids(self): | ||
"""Return the list of user_ids that can validate a given timesheet.""" | ||
self.ensure_one() | ||
for employee in self: | ||
users = [] | ||
if employee and employee.parent_id and employee.parent_id.user_id: | ||
users.append(employee.parent_id.user_id.id) | ||
if ( | ||
employee.department_id | ||
and employee.department_id.manager_id | ||
and employee.department_id.manager_id.user_id | ||
and employee.department_id.manager_id.user_id.id | ||
!= self.env.uid | ||
): | ||
users.append(employee.department_id.manager_id.user_id.id) | ||
elif ( | ||
employee.department_id | ||
and employee.department_id.parent_id | ||
and employee.department_id.parent_id.manager_id | ||
and employee.department_id.parent_id.manager_id.user_id | ||
and employee.department_id.parent_id.manager_id.user_id.id | ||
!= self.env.uid | ||
): | ||
users.append(employee.department_id.manager_id.user_id.id) | ||
return list(set(users)) if users else [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters