Skip to content
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
91 changes: 91 additions & 0 deletions microsoft_calendar_logging/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
==========================================
Microsoft Calendar Synchronization Logging
==========================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:3a3a56b20dd48418b39f82f6627a4a52938888c71710efac94d5a31f333c1278
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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%2Fcalendar-lightgray.png?logo=github
:target: https://github.com/OCA/calendar/tree/16.0/microsoft_calendar_logging
:alt: OCA/calendar
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/calendar-16-0/calendar-16-0-microsoft_calendar_logging
: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/calendar&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

When debugging Microsoft Calender synchronization, it would be usefull to
know wether events where added or updated from microsoft, or the other way
around, and when this happened.

Synchronization events will be logged on the record , except for deletions,
that for obvious reasons will be logged in the system log.

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/calendar/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/OCA/calendar/issues/new?body=module:%20microsoft_calendar_logging%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
~~~~~~~

* Therp BV

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

* `Therp BV <https://therp.nl>`_:

* Ronald Portier (NL66278)

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.

.. |maintainer-NL66278| image:: https://github.com/NL66278.png?size=40px
:target: https://github.com/NL66278
:alt: NL66278

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-NL66278|

This module is part of the `OCA/calendar <https://github.com/OCA/calendar/tree/16.0/microsoft_calendar_logging>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions microsoft_calendar_logging/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import models
19 changes: 19 additions & 0 deletions microsoft_calendar_logging/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2025 Therp BV <https://therp.nl>.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Microsoft Calendar Synchronization Logging",
"summary": "Log synchronization from Microsoft to Odoo and vice versa",
"version": "16.0.1.0.0",
"category": "Appointments",
"website": "https://github.com/OCA/calendar",
"author": "Odoo Community Association (OCA), Therp BV",
"maintainers": ["NL66278"],
"license": "AGPL-3",
"depends": [
"microsoft_calendar",
],
"data": [
"views/calendar_event_views.xml",
],
}
3 changes: 3 additions & 0 deletions microsoft_calendar_logging/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import microsoft_calendar_sync
89 changes: 89 additions & 0 deletions microsoft_calendar_logging/models/microsoft_calendar_sync.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Copyright 2025 Therp BV <https://therp.nl>.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
import logging
import pprint

from odoo import api, fields, models

from odoo.addons.microsoft_account.models.microsoft_service import TIMEOUT

_logger = logging.getLogger(__name__)


class MicrosoftCalendarSync(models.AbstractModel):
"""Track times and direction of synchronization."""

_inherit = "microsoft.calendar.sync"

created_by_synchronization = fields.Boolean(
default=False,
readonly=True,
)
datetime_updated_from_microsoft = fields.Datetime()
datetime_created_on_microsoft = fields.Datetime()
datetime_updated_on_microsoft = fields.Datetime()

def _sync_recurrence_microsoft2odoo(self, microsoft_events, new_events=None):
synced_recurrences, updated_events = super()._sync_recurrence_microsoft2odoo(
microsoft_events, new_events=new_events
)
if synced_recurrences:
synced_recurrences.write({"created_by_synchronization": True})
return synced_recurrences, updated_events

@api.model
def _create_from_microsoft(self, microsoft_event, vals_list):
for vals in vals_list:
vals["created_by_synchronization"] = True
return super()._create_from_microsoft(microsoft_event, vals_list)

def _write_from_microsoft(self, microsoft_event, vals):
vals["datetime_updated_from_microsoft"] = fields.Datetime.now()
return super()._write_from_microsoft(microsoft_event, vals)

def _cancel_microsoft(self):
for this in self:
_logger.info(
"Microsoft deleted %(model)s, (%(id)s, %(name)s)",
{"model": this._name, "id": this.id, "name": this.name},
)
return super()._cancel_microsoft()

def _microsoft_delete(self, user_id, event_id, timeout=TIMEOUT):
"""Log deletion of microsoft record, for either unlinked or archived record."""
# Actual delete on microsoft will run after commit.
for this in self:
_logger.info(
"Deleting event on microsoft for %(model)s, (%(id)s, %(name)s)",
{"model": this._name, "id": this.id, "name": this.name},
)
return super()._microsoft_delete(user_id, event_id, timeout=timeout)

def _microsoft_patch(self, user_id, event_id, values, timeout=TIMEOUT):
"""Mark time record last updated on microsoft from Odoo."""
# Actual update on microsoft will run after commit.
super().write({"datetime_updated_on_microsoft": fields.Datetime.now()})
for this in self:
_logger.info(
"Updating event on microsoft for %(model)s, (%(id)s, %(name)s)",
{"model": this._name, "id": this.id, "name": this.name},
)
_logger.debug(
"Updating event with values: %(values)s",
{"values": pprint.pformat(values)},
)
return super()._microsoft_patch(user_id, event_id, values, timeout=timeout)

def _microsoft_insert(self, values, timeout=TIMEOUT):
"""Mark time record created on microsoft from Odoo."""
# Actual insert on microsoft will run after commit.
super().write({"datetime_created_on_microsoft": fields.Datetime.now()})
for this in self:
_logger.info(
"Inserting event on microsoft for %(model)s, (%(id)s, %(name)s)",
{"model": this._name, "id": this.id, "name": this.name},
)
_logger.debug(
"Inserting with values: %(values)s", {"values": pprint.pformat(values)}
)
return super()._microsoft_insert(values, timeout=timeout)
3 changes: 3 additions & 0 deletions microsoft_calendar_logging/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* `Therp BV <https://therp.nl>`_:

* Ronald Portier (NL66278)
6 changes: 6 additions & 0 deletions microsoft_calendar_logging/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
When debugging Microsoft Calender synchronization, it would be usefull to
know wether events where added or updated from microsoft, or the other way
around, and when this happened.

Synchronization events will be logged on the record , except for deletions,
that for obvious reasons will be logged in the system log.
Loading