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

[16.0] [ADD] event_track_multi_date #327

Open
wants to merge 5 commits into
base: 16.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
60 changes: 60 additions & 0 deletions event_track_multi_date/README.rst
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/coopiteasy/addons/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/coopiteasy/addons/issues/new?body=module:%20event_track_multi_date%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
~~~~~~~

* Coop IT Easy SC

Contributors
~~~~~~~~~~~~

* `Coop IT Easy SC <https://coopiteasy.be>`_

Maintainers
~~~~~~~~~~~

This module is part of the `coopiteasy/addons <https://github.com/coopiteasy/addons/tree/16.0/event_track_multi_date>`_ project on GitHub.

You are welcome to contribute.
1 change: 1 addition & 0 deletions event_track_multi_date/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
19 changes: 19 additions & 0 deletions event_track_multi_date/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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,
}
2 changes: 2 additions & 0 deletions event_track_multi_date/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import event_track
from . import event_track_date
12 changes: 12 additions & 0 deletions event_track_multi_date/models/event_track.py
Original file line number Diff line number Diff line change
@@ -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")
56 changes: 56 additions & 0 deletions event_track_multi_date/models/event_track_date.py
Original file line number Diff line number Diff line change
@@ -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.")
)
1 change: 1 addition & 0 deletions event_track_multi_date/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* `Coop IT Easy SC <https://coopiteasy.be>`_
1 change: 1 addition & 0 deletions event_track_multi_date/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module allows to set multiple dates per track.
3 changes: 3 additions & 0 deletions event_track_multi_date/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading