Closed bvanjeelharia closed 1 year ago
We can't replicate this issue. During our test the sync worked properly. Can you provide a video on how this issue occur?
I don't have the nextcloud instance access for now.But, the way you are handling date fields is incorrect.You can refer this link for more info-https://github.com/python-caldav/caldav/blob/master/examples/basic_usage_examples.py. Lines 143-156 specifically
We are currently using the function "get_event_datetime" in nextcloud_caldav.py. This function takes care of the following:
The function you've referenced only handles date coming from Nextcloud -> Odoo and is not timezone aware in case Nextcloud date is supplied with timezone values.
In order for us to fix the issue, we need to replicate the scenario that eventually lead to the error
Yes, I know that you are using "get_event_datetime" in nextcloud_caldav.py, but it's not working in every case.
The function you've referenced only handles date coming from Nextcloud -> Odoo and is not timezone aware in case Nextcloud date is supplied with timezone values.- it also allows to fetch timezone info from the object.
We can get on a call to discuss further on this.
@Dennis, as discussed on call.Here is the code for your reference: nc_sync_user.py def get_event_data(self, event): """ This method returns the following data of an event: UID, hash, dictionary of event values :param event: Calendar event object :return dictionary of event values """ event_vals = jicson.fromText(event.data).get("VCALENDAR")[0].get("VEVENT") data = [] nc_uid = False
# when event get queried from Nextcloud
dtstart_dt = dtend_dt = tz = False
for d in event_vals:
nc_uid = d["UID"]
d.pop("DTSTAMP")
d.pop("SEQUENCE", False)
exdate_key = [k for k, v in d.items() if "EXDATE" in k]
vevent = event.vobject_instance.vevent
if isinstance(vevent.dtstart.value, datetime):
date_format = "%Y%m%dT%H%M%S"
else:
date_format = "%Y%m%d"
if exdate_key:
tz = False
if "TZID" in exdate_key[0]:
tz = exdate_key[0].split("=")[1]
d.pop(exdate_key[0])
d["exdates"] = [
x.value[0].strftime(date_format) for x in vevent.exdate_list
]
d["exdate_tz"] = tz
dtstart = event.icalendar_component.get("dtstart")
dtstart_dt = dtstart and dtstart.dt
tz = dtstart.params and dtstart.params.get("TZID") or False
dtend = event.icalendar_component.get("dtend")
dtend_dt = dtend and dtend.dt
data.append(d)
vals = {"data": data}
vals["uid"] = nc_uid
json_data = str(json.dumps(vals["data"], sort_keys=True)).encode("utf-8")
vals["hash"] = hashlib.sha1(json_data).hexdigest()
vals['data'][0]["dtstart"] = dtstart_dt
vals['data'][0]["dtend"] = dtend_dt
vals['data'][0]["tz"] = tz
return vals
You can then use this tz info elsewhere
Working fine now
When trying to sync events from Nextcloud to Odoo, getting following error for date time format. Error creating Odoo event time data '20230302T0' does not match format '%Y-%m-%d'
This has something to do from nextcloud end, but it needs to works with all date formats