Code Monkey home page Code Monkey logo

Comments (6)

iscale-odoo avatar iscale-odoo commented on September 27, 2024

We can't replicate this issue. During our test the sync worked properly. Can you provide a video on how this issue occur?

from addons-project-nextcloud.

bvanjeelharia avatar bvanjeelharia commented on September 27, 2024

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

from addons-project-nextcloud.

iscale-odoo avatar iscale-odoo commented on September 27, 2024

We are currently using the function "get_event_datetime" in nextcloud_caldav.py. This function takes care of the following:

  • Both sync direction Odoo (datetime) and Nextcloud (string)
  • Check the timezone if supplied together with the Nextcloud date string then convert to UTC

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

from addons-project-nextcloud.

bvanjeelharia avatar bvanjeelharia commented on September 27, 2024

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.

from addons-project-nextcloud.

bvanjeelharia avatar bvanjeelharia commented on September 27, 2024

@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
# Remove the DTSTAMP values as it always changes
# 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

from addons-project-nextcloud.

bvanjeelharia avatar bvanjeelharia commented on September 27, 2024

Working fine now

from addons-project-nextcloud.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.