-
-
Notifications
You must be signed in to change notification settings - Fork 674
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by max3903
- Loading branch information
Showing
17 changed files
with
833 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,84 @@ | ||
======================== | ||
HR Holidays Team Manager | ||
======================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:ccedfc57a9859a7443298383150ade28cdd0ad1c30437f7a23ed63e2754ed2ae | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Beta | ||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fhr-lightgray.png?logo=github | ||
:target: https://github.com/OCA/hr/tree/16.0/hr_holidays_team_manager | ||
:alt: OCA/hr | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/hr-16-0/hr-16-0-hr_holidays_team_manager | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
:target: https://runboat.odoo-community.org/builds?repo=OCA/hr&target_branch=16.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
Add a new group Time off/Team manager that can only view, write, and create time off | ||
requests and time off assignment requests for employees who belong to the same department | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Usage | ||
===== | ||
|
||
Add a new group Time off/Team manager that can only view, write, and create time off | ||
requests and time off assignment requests for employees who belong to the same department | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/hr/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us to smash it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/hr/issues/new?body=module:%20hr_holidays_team_manager%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* Open Source Integrators | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Murtaza Mithaiwala <mmithaiwala@opensourceintegrators.com> | ||
|
||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
This module is maintained by the OCA. | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
This module is part of the `OCA/hr <https://github.com/OCA/hr/tree/16.0/hr_holidays_team_manager>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
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 @@ | ||
from . import models |
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,19 @@ | ||
# Copyright (C) 2024 - TODAY, Open Source Integrators | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "HR Holidays Team Manager", | ||
"version": "16.0.1.0.0", | ||
"license": "AGPL-3", | ||
"author": "Open Source Integrators, " "Odoo Community Association (OCA)", | ||
"maintainer": "Open Source Integrators", | ||
"website": "https://github.com/OCA/hr", | ||
"category": "HR", | ||
"depends": ["hr_holidays"], | ||
"data": [ | ||
"data/hr_holidays_rules.xml", | ||
"data/hr_holidays_security.xml", | ||
"views/hr_leave_allocation_views.xml", | ||
], | ||
"installable": True, | ||
} |
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,10 @@ | ||
<?xml version='1.0' encoding='utf-8' ?> | ||
<odoo> | ||
<function name="write" model="ir.model.data"> | ||
<value | ||
model="ir.model.data" | ||
search="[('module', '=', 'hr_holidays'), ('name', 'in',['hr_leave_rule_officer_update','hr_leave_allocation_rule_officer_read','hr_leave_allocation_rule_officer_update'])]" | ||
/> | ||
<value eval="{'noupdate': False}" /> | ||
</function> | ||
</odoo> |
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,60 @@ | ||
<?xml version='1.0' encoding='utf-8' ?> | ||
<odoo> | ||
<record id="hr_holidays.group_hr_holidays_user" model="res.groups"> | ||
<field name="name">Time off/Team manager</field> | ||
<field | ||
name="rule_groups" | ||
eval="[(6, 0, [ref('hr_holidays.resource_leaves_holidays_user'), ref('hr_holidays.hr_leave_report_rule_group_holiday_user')])]" | ||
/> | ||
</record> | ||
|
||
<record id="group_hr_holidays_officer" model="res.groups"> | ||
<field name="name">Time off/Holiday Officer</field> | ||
<field | ||
name="implied_ids" | ||
eval="[(4, ref('hr_holidays.group_hr_holidays_user'))]" | ||
/> | ||
<field name="category_id" ref="base.module_category_human_resources_time_off" /> | ||
<field | ||
name="rule_groups" | ||
eval="[(6, 0, [ref('hr_holidays.hr_leave_allocation_rule_officer_update'), ref('hr_holidays.hr_leave_rule_officer_update'),ref('hr_holidays.hr_leave_allocation_rule_officer_read'),ref('hr_holidays.hr_leave_rule_user_read')])]" | ||
/> | ||
</record> | ||
|
||
<record id="hr_holidays.group_hr_holidays_manager" model="res.groups"> | ||
<field | ||
name="implied_ids" | ||
eval="[(6, 0, [ref('hr_holidays_team_manager.group_hr_holidays_officer')])]" | ||
/> | ||
</record> | ||
|
||
<record id="team_manager_time_off_same_department" model="ir.rule"> | ||
<field name="name">Time off: Team manager time off same department</field> | ||
<field name="model_id" ref="hr_holidays.model_hr_leave" /> | ||
<field name="domain_force">['|', | ||
('employee_id.department_id', 'in',[user.employee_ids.department_id.id]), | ||
('employee_ids.department_id', 'in', [user.employee_ids.department_id.id])] | ||
</field> | ||
<field name="groups" eval="[(4, ref('hr_holidays.group_hr_holidays_user'))]" /> | ||
<field name="perm_read" eval="True" /> | ||
<field name="perm_create" eval="True" /> | ||
<field name="perm_write" eval="True" /> | ||
<field name="perm_unlink" eval="True" /> | ||
</record> | ||
|
||
|
||
<record id="team_manager_time_off_allocation_same_department" model="ir.rule"> | ||
<field | ||
name="name" | ||
>Time off: Team manager time off allocation same department</field> | ||
<field name="model_id" ref="hr_holidays.model_hr_leave_allocation" /> | ||
<field name="domain_force">['|', | ||
('employee_id.department_id', 'in', [user.employee_ids.department_id.id]), | ||
('employee_ids.department_id', 'in',[user.employee_ids.department_id.id])]</field> | ||
<field name="groups" eval="[(4, ref('hr_holidays.group_hr_holidays_user'))]" /> | ||
<field name="perm_read" eval="True" /> | ||
<field name="perm_create" eval="True" /> | ||
<field name="perm_write" eval="True" /> | ||
<field name="perm_unlink" eval="True" /> | ||
</record> | ||
</odoo> |
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,2 @@ | ||
from . import hr_employee_base | ||
from . import hr_leave_allocation |
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,53 @@ | ||
# Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
|
||
from odoo import api, models | ||
|
||
|
||
class HrEmployeeBase(models.AbstractModel): | ||
_inherit = "hr.employee.base" | ||
|
||
def search(self, args, offset=0, limit=None, order=None, count=False): | ||
params = self.env.context.get("params") | ||
if params: | ||
model = params.get("model") | ||
if not self.env.context.get("by_pass"): | ||
if ( | ||
model in ["hr.leave", "hr.leave.allocation"] | ||
and self.env.user.has_group("hr_holidays.group_hr_holidays_user") | ||
and not self.env.user.has_group( | ||
"hr_holidays_team_manager.group_hr_holidays_officer" | ||
) | ||
): | ||
if args is None: | ||
args = [] | ||
employee_id = self.env.user.with_context(by_pass=True).employee_ids | ||
if employee_id: | ||
args += [ | ||
("department_id", "=", employee_id[0].department_id.id) | ||
] | ||
|
||
return super().search( | ||
args, offset=offset, limit=limit, order=order, count=count | ||
) | ||
|
||
@api.model | ||
def name_search(self, name="", args=None, operator="ilike", limit=100): | ||
context = self.env.context | ||
if context: | ||
if not self.env.context.get("by_pass"): | ||
if ( | ||
[context.get("hr_leave_allocation") or context.get("hr_leave")] | ||
and self.env.user.has_group("hr_holidays.group_hr_holidays_user") | ||
and not self.env.user.has_group( | ||
"hr_holidays_team_manager.group_hr_holidays_officer" | ||
) | ||
): | ||
if args is None: | ||
args = [] | ||
employee_id = self.env.user.with_context(by_pass=True).employee_ids | ||
if employee_id: | ||
args += [ | ||
("department_id", "=", employee_id[0].department_id.id) | ||
] | ||
|
||
return super().name_search(name=name, args=args, operator=operator, limit=limit) |
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,17 @@ | ||
# Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
|
||
from odoo import _, models | ||
from odoo.exceptions import ValidationError | ||
|
||
|
||
class HolidaysAllocation(models.Model): | ||
_inherit = "hr.leave.allocation" | ||
|
||
def action_validate(self): | ||
if self.env.user.has_group( | ||
"hr_holidays.group_hr_holidays_user" | ||
) and not self.env.user.has_group( | ||
"hr_holidays_team_manager.group_hr_holidays_officer" | ||
): | ||
raise ValidationError(_("Team managers can't approve time off allocations")) | ||
return super().action_validate() |
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,2 @@ | ||
* Murtaza Mithaiwala <mmithaiwala@opensourceintegrators.com> | ||
|
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,2 @@ | ||
Add a new group Time off/Team manager that can only view, write, and create time off | ||
requests and time off assignment requests for employees who belong to the same department |
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,2 @@ | ||
Add a new group Time off/Team manager that can only view, write, and create time off | ||
requests and time off assignment requests for employees who belong to the same department |
Oops, something went wrong.