caldav_sync: fixes #108, warning on invalid operator.

Add a type check to the values being compared when iterating over
current and changed values in a calendar event. Also, rewrite to use
dictionary comprehension for readability.
This commit is contained in:
Marc Durepos 2024-09-05 20:37:50 -04:00
parent 00eb20496c
commit aacc6b27b4
2 changed files with 9 additions and 4 deletions

View file

@ -8,7 +8,7 @@
{ {
"name": "CalDAV Synchronization", "name": "CalDAV Synchronization",
"version": "17.0.0.5.7", "version": "17.0.0.5.8",
"license": "LGPL-3", "license": "LGPL-3",
"category": "Productivity", "category": "Productivity",
"summary": "Synchronize Odoo Calendar Events with CalDAV Servers", "summary": "Synchronize Odoo Calendar Events with CalDAV Servers",

View file

@ -394,9 +394,14 @@ class CalendarEvent(models.Model):
) )
# Don't write values that haven't changed # Don't write values that haven't changed
for key, val in values.items(): changed_vals = {
if getattr(existing_instance, key) != val: key: val
changed_vals.update({key: values.get(key)}) for key, val in values.items()
if (cur_val := getattr(existing_instance, key))
and isinstance(cur_val, type(val))
and cur_val != val
}
if ( if (
recurrency_vals recurrency_vals
and recurrency_vals.get("recurrency") and recurrency_vals.get("recurrency")