diff --git a/event_track_multi_date/README.rst b/event_track_multi_date/README.rst new file mode 100644 index 00000000..7c92d9d2 --- /dev/null +++ b/event_track_multi_date/README.rst @@ -0,0 +1,60 @@ +======================== +Multiple Dates per Track +======================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:0d2b275e6036dd25a6e5507577ac20bace7da2d3d126ac2d8f11bbf0df7edf6e + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-coopiteasy%2Faddons-lightgray.png?logo=github + :target: https://github.com/coopiteasy/addons/tree/16.0/event_track_multi_date + :alt: coopiteasy/addons + +|badge1| |badge2| |badge3| + +This module allows to set multiple dates per track. + +**Table of contents** + +.. contents:: + :local: + +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 +~~~~~~~ + +* Coop IT Easy SC + +Contributors +~~~~~~~~~~~~ + +* `Coop IT Easy SC `_ + +Maintainers +~~~~~~~~~~~ + +This module is part of the `coopiteasy/addons `_ project on GitHub. + +You are welcome to contribute. diff --git a/event_track_multi_date/__init__.py b/event_track_multi_date/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/event_track_multi_date/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/event_track_multi_date/__manifest__.py b/event_track_multi_date/__manifest__.py new file mode 100644 index 00000000..cf65940d --- /dev/null +++ b/event_track_multi_date/__manifest__.py @@ -0,0 +1,19 @@ +# SPDX-FileCopyrightText: 2024 Coop IT Easy SC +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +{ + "name": "Multiple Dates per Track", + "version": "16.0.1.0.0", + "author": "Coop IT Easy SC, Odoo Community Association (OCA)", + "license": "AGPL-3", + "website": "https://github.com/coopiteasy/addons", + "category": "Event", + "summary": "Multiple Dates per Track", + "depends": ["website_event_track"], + "data": [ + "security/ir.model.access.csv", + "views/event_track.xml", + ], + "installable": True, +} diff --git a/event_track_multi_date/models/__init__.py b/event_track_multi_date/models/__init__.py new file mode 100644 index 00000000..d406a2f6 --- /dev/null +++ b/event_track_multi_date/models/__init__.py @@ -0,0 +1,2 @@ +from . import event_track +from . import event_track_date diff --git a/event_track_multi_date/models/event_track.py b/event_track_multi_date/models/event_track.py new file mode 100644 index 00000000..5a0685c0 --- /dev/null +++ b/event_track_multi_date/models/event_track.py @@ -0,0 +1,12 @@ +# SPDX-FileCopyrightText: 2024 Coop IT Easy SC +# +# SPDX-License-Identifier: AGPL-3.0-or-later + + +from odoo import fields, models + + +class EventTrackSession(models.Model): + _inherit = "event.track" + + dates = fields.One2many(comodel_name="event.track.date", inverse_name="track_id") diff --git a/event_track_multi_date/models/event_track_date.py b/event_track_multi_date/models/event_track_date.py new file mode 100644 index 00000000..a6191088 --- /dev/null +++ b/event_track_multi_date/models/event_track_date.py @@ -0,0 +1,56 @@ +# SPDX-FileCopyrightText: 2024 Coop IT Easy SC +# +# SPDX-License-Identifier: AGPL-3.0-or-later + + +from datetime import datetime + +from odoo import _, api, fields, models +from odoo.exceptions import ValidationError + + +class EventTrackDate(models.Model): + _name = "event.track.date" + _description = "Track dates" + + def _default_datetime(self): + event_id = self.env.context.get("event_id") + if event_id: + event = self.env["event.event"].browse(event_id) + return event.date_begin + return None + + track_id = fields.Many2one("event.track") + event_id = fields.Many2one(related="track_id.event_id") + datetime = fields.Datetime(string="Date and time", default=_default_datetime) + date = fields.Date(compute="_compute_date_and_time") + hour = fields.Float(string="Hours", compute="_compute_date_and_time") + + @api.depends("datetime") + def _compute_date_and_time(self): + for track_date in self: + if track_date.datetime: + track_date.date = track_date.datetime.date() + track_date.hour = ( + fields.Datetime.context_timestamp( + self.env.user, track_date.datetime + ) + - fields.Datetime.context_timestamp( + self.env.user, + datetime.combine(track_date.date, datetime.min.time()), + ).replace(hour=0, minute=0, second=0) + ).total_seconds() / 3600 + else: + track_date.date = False + track_date.hour = False + + @api.constrains("datetime") + def _constrain_datetime_valid(self): + for track in self: + if ( + track.datetime < track.event_id.date_begin + or track.datetime > track.event_id.date_end + ): + raise ValidationError( + _("Date must match the event dates of the track.") + ) diff --git a/event_track_multi_date/readme/CONTRIBUTORS.rst b/event_track_multi_date/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..da71d59f --- /dev/null +++ b/event_track_multi_date/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* `Coop IT Easy SC `_ diff --git a/event_track_multi_date/readme/DESCRIPTION.rst b/event_track_multi_date/readme/DESCRIPTION.rst new file mode 100644 index 00000000..ec58df20 --- /dev/null +++ b/event_track_multi_date/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module allows to set multiple dates per track. diff --git a/event_track_multi_date/security/ir.model.access.csv b/event_track_multi_date/security/ir.model.access.csv new file mode 100644 index 00000000..3302a5b0 --- /dev/null +++ b/event_track_multi_date/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_event_track_date_registration,event.track.date.registration,event_track_multi_date.model_event_track_date,event.group_event_registration_desk,1,0,0,0 +access_event_track_date_user,event.track.date.user,event_track_multi_date.model_event_track_date,event.group_event_user,1,1,1,1 diff --git a/event_track_multi_date/static/description/icon.png b/event_track_multi_date/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/event_track_multi_date/static/description/icon.png differ diff --git a/event_track_multi_date/static/description/index.html b/event_track_multi_date/static/description/index.html new file mode 100644 index 00000000..58c34eb6 --- /dev/null +++ b/event_track_multi_date/static/description/index.html @@ -0,0 +1,416 @@ + + + + + +Multiple Dates per Track + + + +
+

Multiple Dates per Track

+ + +

Beta License: AGPL-3 coopiteasy/addons

+

This module allows to set multiple dates per track.

+

Table of contents

+ +
+

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

+
    +
  • Coop IT Easy SC
  • +
+
+ +
+

Maintainers

+

This module is part of the coopiteasy/addons project on GitHub.

+

You are welcome to contribute.

+
+
+
+ + diff --git a/event_track_multi_date/views/event_track.xml b/event_track_multi_date/views/event_track.xml new file mode 100644 index 00000000..f98db7a0 --- /dev/null +++ b/event_track_multi_date/views/event_track.xml @@ -0,0 +1,19 @@ + + + + event.track + + + + True + + + + + + + + + + + diff --git a/setup/event_track_multi_date/odoo/addons/event_track_multi_date b/setup/event_track_multi_date/odoo/addons/event_track_multi_date new file mode 120000 index 00000000..4bc7150a --- /dev/null +++ b/setup/event_track_multi_date/odoo/addons/event_track_multi_date @@ -0,0 +1 @@ +../../../../event_track_multi_date \ No newline at end of file diff --git a/setup/event_track_multi_date/setup.py b/setup/event_track_multi_date/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/event_track_multi_date/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)