diff --git a/hr_shift_ical/README.rst b/hr_shift_ical/README.rst new file mode 100644 index 0000000..616dd63 --- /dev/null +++ b/hr_shift_ical/README.rst @@ -0,0 +1,92 @@ +===================================== +Employees Shifts - Personal iCalendar +===================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:778ec09240e767a17507a4d2da52155f66bc87a76aef821dfa2150592b2d5730 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fshift--planning-lightgray.png?logo=github + :target: https://github.com/OCA/shift-planning/tree/18.0/hr_shift_ical + :alt: OCA/shift-planning +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/shift-planning-18-0/shift-planning-18-0-hr_shift_ical + :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/shift-planning&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Publish each employee's shift planning as a personal read-only iCalendar +feed via base_ical. Every internal user can generate a personal URL from +their preferences and subscribe to it from Google Calendar, Apple +Calendar or Outlook. Each user only sees their own shifts. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +1. Open your user preferences and go to the *iCalendar URLs* section. +2. Generate a URL for the *My shifts* calendar; you will be asked to + re-enter your password. +3. Paste the URL in the *Add calendar by URL* option of your calendar + client. + +By default, the feed exposes shifts from 30 days in the past to 90 days +in the future. An administrator can adjust the window by editing the *My +shifts* calendar record's domain (*Technical › iCalendar › Calendars*). + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* INVITU + +Contributors +------------ + +- Cyril VINH-TUNG <> + +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/shift-planning `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/hr_shift_ical/__init__.py b/hr_shift_ical/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/hr_shift_ical/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/hr_shift_ical/__manifest__.py b/hr_shift_ical/__manifest__.py new file mode 100644 index 0000000..95801f0 --- /dev/null +++ b/hr_shift_ical/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2026 INVITU () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +{ + "name": "Employees Shifts - Personal iCalendar", + "summary": "Publish employee shifts as a personal read-only iCalendar feed", + "version": "18.0.1.0.0", + "development_status": "Alpha", + "author": "INVITU, Odoo Community Association (OCA)", + "license": "AGPL-3", + "website": "https://github.com/OCA/shift-planning", + "category": "Human Resources/Shifts", + "depends": ["hr_shift", "base_ical"], + "data": [ + "data/base_ical.xml", + ], +} diff --git a/hr_shift_ical/data/base_ical.xml b/hr_shift_ical/data/base_ical.xml new file mode 100644 index 0000000..95a7dae --- /dev/null +++ b/hr_shift_ical/data/base_ical.xml @@ -0,0 +1,22 @@ + + + + + + My shifts + + [ + ('employee_id.user_id', '=', user.id), + ('state', '=', 'assigned'), + ('start_time', '>=', (datetime.now() - timedelta(days=30)).strftime('%Y-%m-%d')), + ('start_time', '<=', (datetime.now() + timedelta(days=90)).strftime('%Y-%m-%d')), + ] + 'hr-shift-line-%s@%s' % (record.id, user.login) + record.start_time + record.end_time + record.template_id.name or 'Shift' + + + diff --git a/hr_shift_ical/models/__init__.py b/hr_shift_ical/models/__init__.py new file mode 100644 index 0000000..b10e9c5 --- /dev/null +++ b/hr_shift_ical/models/__init__.py @@ -0,0 +1 @@ +from . import base_ical diff --git a/hr_shift_ical/models/base_ical.py b/hr_shift_ical/models/base_ical.py new file mode 100644 index 0000000..912f1bc --- /dev/null +++ b/hr_shift_ical/models/base_ical.py @@ -0,0 +1,14 @@ +# Copyright 2026 INVITU () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from datetime import datetime, timedelta + +from odoo import models + + +class BaseIcal(models.Model): + _inherit = "base.ical" + + def _get_eval_domain_context(self): + res = super()._get_eval_domain_context() + res.update({"datetime": datetime, "timedelta": timedelta}) + return res diff --git a/hr_shift_ical/pyproject.toml b/hr_shift_ical/pyproject.toml new file mode 100644 index 0000000..4231d0c --- /dev/null +++ b/hr_shift_ical/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/hr_shift_ical/readme/CONTRIBUTORS.md b/hr_shift_ical/readme/CONTRIBUTORS.md new file mode 100644 index 0000000..c3b98a9 --- /dev/null +++ b/hr_shift_ical/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +- Cyril VINH-TUNG <\> diff --git a/hr_shift_ical/readme/DESCRIPTION.md b/hr_shift_ical/readme/DESCRIPTION.md new file mode 100644 index 0000000..8188932 --- /dev/null +++ b/hr_shift_ical/readme/DESCRIPTION.md @@ -0,0 +1 @@ +Publish each employee's shift planning as a personal read-only iCalendar feed via base_ical. Every internal user can generate a personal URL from their preferences and subscribe to it from Google Calendar, Apple Calendar or Outlook. Each user only sees their own shifts. diff --git a/hr_shift_ical/readme/USAGE.md b/hr_shift_ical/readme/USAGE.md new file mode 100644 index 0000000..410966c --- /dev/null +++ b/hr_shift_ical/readme/USAGE.md @@ -0,0 +1,5 @@ +1. Open your user preferences and go to the *iCalendar URLs* section. +2. Generate a URL for the *My shifts* calendar; you will be asked to re-enter your password. +3. Paste the URL in the *Add calendar by URL* option of your calendar client. + +By default, the feed exposes shifts from 30 days in the past to 90 days in the future. An administrator can adjust the window by editing the *My shifts* calendar record's domain (*Technical › iCalendar › Calendars*). diff --git a/hr_shift_ical/static/description/index.html b/hr_shift_ical/static/description/index.html new file mode 100644 index 0000000..4ffda43 --- /dev/null +++ b/hr_shift_ical/static/description/index.html @@ -0,0 +1,440 @@ + + + + + +Employees Shifts - Personal iCalendar + + + +
+

Employees Shifts - Personal iCalendar

+ + +

Beta License: AGPL-3 OCA/shift-planning Translate me on Weblate Try me on Runboat

+

Publish each employee’s shift planning as a personal read-only iCalendar +feed via base_ical. Every internal user can generate a personal URL from +their preferences and subscribe to it from Google Calendar, Apple +Calendar or Outlook. Each user only sees their own shifts.

+

Table of contents

+ +
+

Usage

+
    +
  1. Open your user preferences and go to the iCalendar URLs section.
  2. +
  3. Generate a URL for the My shifts calendar; you will be asked to +re-enter your password.
  4. +
  5. Paste the URL in the Add calendar by URL option of your calendar +client.
  6. +
+

By default, the feed exposes shifts from 30 days in the past to 90 days +in the future. An administrator can adjust the window by editing the My +shifts calendar record’s domain (Technical › iCalendar › Calendars).

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • INVITU
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

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/shift-planning project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/hr_shift_ical/tests/__init__.py b/hr_shift_ical/tests/__init__.py new file mode 100644 index 0000000..ed8b165 --- /dev/null +++ b/hr_shift_ical/tests/__init__.py @@ -0,0 +1 @@ +from . import test_hr_shift_ical diff --git a/hr_shift_ical/tests/test_hr_shift_ical.py b/hr_shift_ical/tests/test_hr_shift_ical.py new file mode 100644 index 0000000..3c1af7f --- /dev/null +++ b/hr_shift_ical/tests/test_hr_shift_ical.py @@ -0,0 +1,14 @@ +# Copyright 2026 INVITU () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from odoo.tests import TransactionCase + + +class TestHrShiftIcal(TransactionCase): + def test_config_targets_shift_lines(self): + config = self.env.ref("hr_shift_ical.hr_shift_ical_config") + self.assertEqual(config.model, "hr.shift.planning.line") + self.assertTrue(config.auto) + + def test_domain_evaluates_without_error(self): + config = self.env.ref("hr_shift_ical.hr_shift_ical_config") + config._get_items(limit=1)