Significant improvements to the code around synchronizing events, especially recurring ones. Too much has changed to explain fully here, so read the changelog in README.rst or read the code. Squashed commit of the following: commite537a7f7f4Author: Marc Durepos <marc@bemade.org> Date: Fri Nov 8 15:47:39 2024 -0500 caldav_sync: getting ready for launch of 0.6.0 commit5797f8efcaAuthor: Marc Durepos <marc@bemade.org> Date: Fri Nov 8 12:41:13 2024 -0500 fixup! caldav_sync: all seems good. further testing to come before merging into 17.0 commit992778e353Author: Marc Durepos <marc@bemade.org> Date: Fri Nov 8 12:41:02 2024 -0500 caldav_sync: all seems good. further testing to come before merging into 17.0 commit90d05d75a2Author: Marc Durepos <marc@bemade.org> Date: Fri Nov 8 11:31:14 2024 -0500 caldav_sync: better sync with calls to _rewrite_recurrence commit5ca1d56e54Author: Marc Durepos <marc@bemade.org> Date: Thu Nov 7 16:13:31 2024 -0500 caldav_sync: recurrence working from Odoo to CalDAV. Need further testing for the other direction. commitce7b27cc65Author: Marc Durepos <marc@bemade.org> Date: Thu Nov 7 10:33:26 2024 -0500 caldav_sync: updating recurrences in the middle with future works, but it breaks singled out events before it (brings them back into the rrule chain) commit421d609abdAuthor: Marc Durepos <marc@bemade.org> Date: Thu Nov 7 08:08:35 2024 -0500 caldav_sync: still working on recurrence commit0e07d42825Author: Marc Durepos <marc@bemade.org> Date: Wed Nov 6 16:06:43 2024 -0500 caldav_sync: moving a single event in a recurrence is synchronizing well commit14a8b6acf0Author: Marc Durepos <marc@bemade.org> Date: Wed Nov 6 13:53:23 2024 -0500 caldav_sync: CRUD fully functional, recurring events working with exceptions around changes in mid-sequence with rrule updates commit068d1fb29fAuthor: Marc Durepos <marc@bemade.org> Date: Tue Nov 5 16:42:42 2024 -0500 caldav_sync: all CRUD operations working. Recurrences working to some degree but not fully. commit0104e3897cAuthor: Marc Durepos <marc@bemade.org> Date: Mon Nov 4 07:48:48 2024 -0500 caldav_sync: major rework underway. This commit is broken.
39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
from odoo import models, fields, api
|
|
import uuid
|
|
import logging
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
|
|
class RecurrenceRule(models.Model):
|
|
_inherit = "calendar.recurrence"
|
|
|
|
caldav_uid = fields.Char(
|
|
readonly=True,
|
|
copy=False,
|
|
)
|
|
_sql_constraints = [
|
|
("caldav_uid_unique", "UNIQUE (caldav_uid)", "caldav_uid must be unique")
|
|
]
|
|
|
|
@api.model_create_multi
|
|
def create(self, vals_list):
|
|
if not self._context.get("caldav_keep_ids"):
|
|
for vals in vals_list:
|
|
vals["caldav_uid"] = str(uuid.uuid4())
|
|
else:
|
|
for vals in vals_list:
|
|
base_event = self.env["calendar.event"].browse(vals["base_event_id"])
|
|
vals.update(caldav_uid=base_event.caldav_uid)
|
|
return super().create(vals_list)
|
|
|
|
@api.model
|
|
def _detach_events(self, events):
|
|
"""When events are detached from a recurrence, their CalDAV UID and recurrence-id
|
|
are no longer going to be valid, so we remove them from the server. They may then
|
|
be re-written to the server with their new IDs later, but we don't care about
|
|
that here."""
|
|
detached_events = super()._detach_events(events)
|
|
for event in detached_events:
|
|
event._sync_unlink_to_caldav()
|
|
return detached_events
|