-
-
Notifications
You must be signed in to change notification settings - Fork 110
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 dreispt
- Loading branch information
Showing
14 changed files
with
125 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 @@ | ||
to auto generate |
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,21 @@ | ||
# Copyright 2023 Camptocamp SA | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) | ||
{ | ||
"name": "Hr holidays calendar events privacy", | ||
"summary": "Define privacy level of calendar events from Time off requests", | ||
"version": "15.0.1.0.0", | ||
"development_status": "Alpha", | ||
"category": "Human Resources", | ||
"website": "https://github.com/OCA/hr-holidays", | ||
"author": "Camptocamp, Odoo Community Association (OCA)", | ||
"maintainers": ["grindtildeath"], | ||
"license": "AGPL-3", | ||
"application": False, | ||
"installable": True, | ||
"depends": [ | ||
"hr_holidays", | ||
], | ||
"data": [ | ||
"views/hr_leave_type.xml", | ||
], | ||
} |
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_leave_type | ||
from . import hr_leave |
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,18 @@ | ||
# Copyright 2023 Camptocamp SA | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) | ||
from odoo import models | ||
from odoo.tools import groupby | ||
|
||
|
||
class HrLeave(models.Model): | ||
_inherit = "hr.leave" | ||
|
||
def _prepare_holidays_meeting_values(self): | ||
"""Set calendar events privacy for hr leaves according to type""" | ||
res = super()._prepare_holidays_meeting_values() | ||
for user, holidays in groupby(self, lambda h: h.user_id): | ||
for holiday, meeting_vals in zip(holidays, res.get(user.id)): | ||
meeting_vals[ | ||
"privacy" | ||
] = holiday.holiday_status_id.calendar_event_privacy | ||
return res |
17 changes: 17 additions & 0 deletions
17
hr_holidays_calendar_event_privacy/models/hr_leave_type.py
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 @@ | ||
# Copyright 2023 Camptocamp SA | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) | ||
from odoo import fields, models | ||
|
||
|
||
class HrLeaveType(models.Model): | ||
_inherit = "hr.leave.type" | ||
|
||
calendar_event_privacy = fields.Selection( | ||
[ | ||
("public", "Public"), | ||
("private", "Private"), | ||
("confidential", "Only internal users"), | ||
], | ||
default="confidential", | ||
help="Defines privacy of calendar events created for this Time Off Type", | ||
) |
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,3 @@ | ||
In Time Off > Configuration > Time Off Types, you can define | ||
the privacy level that will be used to create calendar events | ||
for Time Off Requests of this type. |
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 @@ | ||
* Akim Juillerat <[email protected]> |
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 @@ | ||
This module allows to redefine the privacy level of calendar | ||
events created from Time off requests. |
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 test_hr_leave_calendar_event |
38 changes: 38 additions & 0 deletions
38
hr_holidays_calendar_event_privacy/tests/test_hr_leave_calendar_event.py
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,38 @@ | ||
# Copyright 2023 Camptocamp SA | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) | ||
from datetime import timedelta | ||
|
||
from odoo import fields | ||
from odoo.tests import Form, TransactionCase | ||
|
||
|
||
class TestHrLeaveCalendarEvent(TransactionCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
cls.admin_user = cls.env.ref("base.user_admin") | ||
cls.leave_type = cls.env.ref("hr_holidays.holiday_status_cl") | ||
|
||
@classmethod | ||
def _new_leave_request(cls, date_from, date_to): | ||
leave_form = Form(cls.env["hr.leave"].with_user(cls.admin_user)) | ||
leave_form.holiday_status_id = cls.leave_type | ||
leave_form.date_from = date_from | ||
leave_form.date_to = date_to | ||
return leave_form.save() | ||
|
||
def test_calendar_event_privacy(self): | ||
self.assertEqual(self.leave_type.calendar_event_privacy, "confidential") | ||
leave = self._new_leave_request( | ||
fields.Date.today() + timedelta(days=12), | ||
fields.Date.today() + timedelta(days=13), | ||
) | ||
leave.action_validate() | ||
self.assertEqual(leave.meeting_id.privacy, "confidential") | ||
self.leave_type.calendar_event_privacy = "public" | ||
leave = self._new_leave_request( | ||
fields.Date.today() + timedelta(days=13), | ||
fields.Date.today() + timedelta(days=14), | ||
) | ||
leave.action_validate() | ||
self.assertEqual(leave.meeting_id.privacy, "public") |
13 changes: 13 additions & 0 deletions
13
hr_holidays_calendar_event_privacy/views/hr_leave_type.xml
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,13 @@ | ||
<?xml version='1.0' encoding='UTF-8' ?> | ||
<odoo> | ||
<record id="edit_holiday_status_form_inherit" model="ir.ui.view"> | ||
<field name="name">hr.leave.type.form.inherit</field> | ||
<field name="model">hr.leave.type</field> | ||
<field name="inherit_id" ref="hr_holidays.edit_holiday_status_form" /> | ||
<field name="arch" type="xml"> | ||
<field name="time_type" position="after"> | ||
<field name="calendar_event_privacy" /> | ||
</field> | ||
</field> | ||
</record> | ||
</odoo> |
1 change: 1 addition & 0 deletions
1
setup/hr_holidays_calendar_event_privacy/odoo/addons/hr_holidays_calendar_event_privacy
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 @@ | ||
../../../../hr_holidays_calendar_event_privacy |
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,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |