Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[17.0][MIG] hr_holidays_team_manager: Migration to 17.0 #1450

Open
wants to merge 7 commits into
base: 17.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions hr_holidays_team_manager/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
========================
HR Holidays Team Manager
========================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:f58b08309a0ee64587893004030bb9f490a487dabec4f41a792781b6528f5be2
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/17.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-17-0/hr-17-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=17.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:%2017.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 <[email protected]>
- `Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>`__

- Bhavesh Heliconia

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/17.0/hr_holidays_team_manager>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions hr_holidays_team_manager/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
19 changes: 19 additions & 0 deletions hr_holidays_team_manager/__manifest__.py
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": "17.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,
}
10 changes: 10 additions & 0 deletions hr_holidays_team_manager/data/hr_holidays_rules.xml
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>
66 changes: 66 additions & 0 deletions hr_holidays_team_manager/data/hr_holidays_security.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?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="[Command.set([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="[Command.set([ref('hr_holidays.group_hr_holidays_user')])]"
/>
<field name="category_id" ref="base.module_category_human_resources_time_off" />
<field
name="rule_groups"
eval="[Command.set([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="[Command.set([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="[Command.link(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="[Command.link(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>
36 changes: 36 additions & 0 deletions hr_holidays_team_manager/i18n/hr_holidays_team_manager.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * hr_holidays_team_manager
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: hr_holidays_team_manager
#: model:ir.model,name:hr_holidays_team_manager.model_hr_employee_base
msgid "Basic Employee"
msgstr ""

#. module: hr_holidays_team_manager
#. odoo-python
#: code:addons/hr_holidays_team_manager/models/hr_leave_allocation.py:0
#, python-format
msgid "Team managers can't approve time off allocations"
msgstr ""

#. module: hr_holidays_team_manager
#: model:ir.model,name:hr_holidays_team_manager.model_hr_leave_allocation
msgid "Time Off Allocation"
msgstr ""

#. module: hr_holidays_team_manager
#: model:res.groups,name:hr_holidays_team_manager.group_hr_holidays_officer
msgid "Time off/Holiday Officer"
msgstr ""
39 changes: 39 additions & 0 deletions hr_holidays_team_manager/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * hr_holidays_team_manager
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-12-09 11:06+0000\n"
"Last-Translator: mymage <[email protected]>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 5.6.2\n"

#. module: hr_holidays_team_manager
#: model:ir.model,name:hr_holidays_team_manager.model_hr_employee_base
msgid "Basic Employee"
msgstr "Dipendente base"

#. module: hr_holidays_team_manager
#. odoo-python
#: code:addons/hr_holidays_team_manager/models/hr_leave_allocation.py:0
#, python-format
msgid "Team managers can't approve time off allocations"
msgstr "I manager del gruppo non possono approvare le allocazioni delle assenze"

#. module: hr_holidays_team_manager
#: model:ir.model,name:hr_holidays_team_manager.model_hr_leave_allocation
msgid "Time Off Allocation"
msgstr "Allocazione assenza"

#. module: hr_holidays_team_manager
#: model:res.groups,name:hr_holidays_team_manager.group_hr_holidays_officer
msgid "Time off/Holiday Officer"
msgstr "Funzionario assenze/ferie"
2 changes: 2 additions & 0 deletions hr_holidays_team_manager/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import hr_employee_base
from . import hr_leave_allocation
51 changes: 51 additions & 0 deletions hr_holidays_team_manager/models/hr_employee_base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# 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, domain, offset=0, limit=None, order=None):
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 domain is None:
domain = []

Check warning on line 22 in hr_holidays_team_manager/models/hr_employee_base.py

View check run for this annotation

Codecov / codecov/patch

hr_holidays_team_manager/models/hr_employee_base.py#L22

Added line #L22 was not covered by tests
employee_id = self.env.user.with_context(by_pass=True).employee_ids
if employee_id:
domain += [
("department_id", "=", employee_id[0].department_id.id)
]

return super().search(domain, offset=offset, limit=limit, order=order)

@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)
17 changes: 17 additions & 0 deletions hr_holidays_team_manager/models/hr_leave_allocation.py
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()

Check warning on line 17 in hr_holidays_team_manager/models/hr_leave_allocation.py

View check run for this annotation

Codecov / codecov/patch

hr_holidays_team_manager/models/hr_leave_allocation.py#L17

Added line #L17 was not covered by tests
3 changes: 3 additions & 0 deletions hr_holidays_team_manager/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
3 changes: 3 additions & 0 deletions hr_holidays_team_manager/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Murtaza Mithaiwala \<<[email protected]>\>
- [Heliconia Solutions Pvt. Ltd.](https://www.heliconia.io)
- Bhavesh Heliconia
3 changes: 3 additions & 0 deletions hr_holidays_team_manager/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
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
3 changes: 3 additions & 0 deletions hr_holidays_team_manager/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading