Search code examples
pythonexceptiongoogle-calendar-apiodoopython-dateutil

Odoo - Python exception while integrating Google Calendar


I have encountered an issue while synchronising the odoo calendar with google's one after integrating the Google Calendar's module and allowing the API access.

The following exception is raised after clicking the synch button on odoo's calendar

    File "/opt/odoo/addons/calendar/calendar.py", line 1328, in _parse_rrule
data['day'] = r._bymonthday[0]

TypeError: 'set' object does not support indexing

The odoo version I am using is v9


Solution

  • Important observation :

    This situation is specefic to odoo 9, it have been fixed since then. So if you are able to migrate your data from the current version to a later one the problem would not apear then. Otherwise, please follow carefully the below answer.

    1. Explanation

    The exception that is raised could be due to installed python-dateutil's version.

    Some attribute types in the python-dateutil's 2.4.x (and upper) versions have been modified from listto set. A good idea would be to downgrade python-dateutil version from the current to 2.2 where the attributes have the same expected type for the synchronisation.

    This question have been asked, and answered, in the odoo's official forum. You can visit this link.

    2. Solution

    In order to solve this problem, you should follow the steps below :

    1. Check dateutil's current version
    2. Downgrade dateutil version to 2.2 (if applicable)
    3. Make sure that the module is downgraded
    4. Restart odoo server
    5. Test google calendar synchronisation

    These steps are detailed below :

    2.1. Check dateutil version

    Go to the machine's command prompt (terminal), whatever may be the OS, and type the following commands :

    $ python
    >>> import dateutil
    >>> dateutil.__version__
    

    If the version is 2.4 the output would be :

    '2.4.0'
    

    2.2. Downgrade dateutil version to 2.2

    You better have pip installed in your machine so you can type :

    $ pip install python-dateutil==2.2
    

    This would automatically uninstall current version and install the 2.2 instead.

    2.3. Make sure that the module is downgraded

    Do the step 2.1 all over and make sure the output is :

    '2.2.0'
    

    2.4. Restart odoo server

    If you have odoo installed as a service you can restart it as follows :

    service odoo-server restart
    

    or (for Windows) :

    sc start odoo-server
    

    Else, you'd have to kill the process (according to the used OS) that is running the odoo server, then go where the odoo.py (or odoo-bin for odoo >= 10.0) is located and run it again. (This is not recommended, it's better to run it as a service)

    2.5. Test google calendar synchronisation

    Go to odoo, open the Calendar application, then click the Sync with Google button and that should be it.