Code Monkey home page Code Monkey logo

addons-project-nextcloud's People

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

addons-project-nextcloud's Issues

Refactor nextcloud_caldav.py

Good practice says:

Functions and methods should not contain too much logic: having a lot of small and simple methods is more advisable than having few large and complex methods.

as stated in standard Odoo documentation: https://www.odoo.com/documentation/15.0/contributing/development/coding_guidelines.html#think-extendable

Now looking at file nextcloud_caldav.py, the overall logic has a low readability and makes it difficult to review and debug.
The file itself contains more that 1500 lines and some methods also contain a lot of lines.

Although this file is supposed to contain a definition of an an abstract model only, there are may parts of code where records of standard modules (like "calendar.event", "res.users", "res.partner", "calendar.event.type", etc..) are referred. This means that part of the logic could be moved into the files inheriting from standard modules.

Issue with deleting Nextcloud users in Odoo

After selecting multiple users to delete in Odoo we got the following error:

image

RPC_ERROR
Odoo Server Error
Traceback (most recent call last):
File "/opt/odoo/odoo-server/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
result = request.dispatch()
File "/opt/odoo/odoo-server/odoo/http.py", line 687, in dispatch
result = self._call_function(**self.params)
File "/opt/odoo/odoo-server/odoo/http.py", line 359, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/opt/odoo/odoo-server/odoo/service/model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "/opt/odoo/odoo-server/odoo/http.py", line 348, in checked_call
result = self.endpoint(*a, **kw)
File "/opt/odoo/odoo-server/odoo/http.py", line 916, in call
return self.method(*args, **kw)
File "/opt/odoo/odoo-server/odoo/http.py", line 535, in response_wrap
response = f(*args, **kw)
File "/opt/odoo/odoo-server/addons/web/controllers/main.py", line 1342, in call_kw
return self._call_kw(model, method, args, kwargs)
File "/opt/odoo/odoo-server/addons/web/controllers/main.py", line 1334, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/opt/odoo/odoo-server/odoo/api.py", line 464, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "/opt/odoo/odoo-server/odoo/api.py", line 451, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "/opt/odoo/custom/addons/addons-customer-nextcloud/nextcloud_odoo_sync/models/nc_sync_user.py", line 129, in unlink
[("user_id", "=", self.user_id.id)]
File "/opt/odoo/odoo-server/odoo/fields.py", line 4069, in get
raise ValueError("Expected singleton: %s" % record)
Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/opt/odoo/odoo-server/odoo/http.py", line 643, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/opt/odoo/odoo-server/odoo/http.py", line 301, in _handle_exception
raise exception.with_traceback(None) from new_cause
ValueError: Expected singleton: res.users(8, 6, 11, 2)

Issues while syncing events from odoo to nextcloud

When an event is created in Odoo and if we add location,categories, all day etc. , its not getting reflected in nextcloud

Also, when category is added in Odoo and when that event is being synced to nextloud, getting error in sync activity logs as :
Error updating Nextcloud event "Test Privacy" for user "Mitchell Admin":
categories

Issue Sync Nextcloud > Odoo

Test with version 15.0.1.2.

Event sync from Nextcloud > Odoo > no event in Odoo

Event in Nextcloud

image

No event in Odoo

image

Access rights issue:Users with sync user access are able to see,edit and add user setup for other users

Currently, users with Nextcloud Sync - Sync User access are able to see configuration as well from where they can see,edit and add user setup for other users which shouldn't be the case.

Ideally, there should be just one group- Nextcloud Sync - Sync Admin, users with this access should be able to manage user setup for users as well as run sync.For other users, they shouldn't have access to the Nextcloud Sync Menu Itself.They should just have access to the user setup from user profile and a button should be added there which would allow to sync only their events.

So , basically users with Sync Admin should be able to sync events for all users while others should just be able to sync theirs.

Please check this and let me know in case you have queries

Code Review: Remove Unwanted Libraries

Although it is a part of the OCA guidelines that I will be sharing with you, but it might get missed out, so please make sure you don't have any unused libraries in your code , be it Python or JS

Issues from previous meeting: 2023-03-17

Issue encountered during the last meeting:

  1. There are still issues on the sync that are related to shared calendar events. We tried to clear all Odoo events then do another sync but the following issues were still encountered:
    • Record does not exist or has been deleted (Record: calendar.event(1724,), User: 2) - When syncing admin account
    • Error saving event 'Test NC Calendar' for user 'Randy Charleston': 'bool' object has no attribute 'uid'
  2. Need to improve the function that handles the mapping of Nextcloud user to its equivalent Odoo user account to prevent duplicate event from occuring because of the difference with attendees
    • This can be resolve by saving the email address of the Nextcloud user to Odoo Sync user form

Error when sync from Nextcloud to Odoo

The module is updated to version 15.0.1.1.
When sync from Nextcloud to Odoo the following error comes:

RPC_ERROR
Odoo Server Error
Traceback (most recent call last):
File "/opt/odoo/odoo-server/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
result = request.dispatch()
File "/opt/odoo/odoo-server/odoo/http.py", line 687, in dispatch
result = self._call_function(**self.params)
File "/opt/odoo/odoo-server/odoo/http.py", line 359, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/opt/odoo/odoo-server/odoo/service/model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "/opt/odoo/odoo-server/odoo/http.py", line 348, in checked_call
result = self.endpoint(*a, **kw)
File "/opt/odoo/odoo-server/odoo/http.py", line 916, in call
return self.method(*args, **kw)
File "/opt/odoo/odoo-server/odoo/http.py", line 535, in response_wrap
response = f(*args, **kw)
File "/opt/odoo/odoo-server/addons/web/controllers/main.py", line 1346, in call_button
action = self._call_kw(model, method, args, kwargs)
File "/opt/odoo/odoo-server/addons/web/controllers/main.py", line 1334, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/opt/odoo/odoo-server/odoo/api.py", line 464, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "/opt/odoo/odoo-server/odoo/api.py", line 451, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "/opt/odoo/custom/addons/addons-customer-nextcloud/nextcloud_odoo_sync/wizards/run_sync_wizard.py", line 11, in run_sync_cron
self.env["nextcloud.caldav"].sync_cron()
File "/opt/odoo/custom/addons/addons-customer-nextcloud/nextcloud_odoo_sync/models/nextcloud_caldav.py", line 1260, in sync_cron
params = self.update_odoo_events(user, od_events_dict, **params)
File "/opt/odoo/custom/addons/addons-customer-nextcloud/nextcloud_odoo_sync/models/nextcloud_caldav.py", line 699, in update_odoo_events
event_name = vals["name"]
Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/opt/odoo/odoo-server/odoo/http.py", line 643, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/opt/odoo/odoo-server/odoo/http.py", line 301, in _handle_exception
raise exception.with_traceback(None) from new_cause
KeyError: 'name'

Event deleted from Nextcloud - Odoo

After update 15.0.1.1.

When organizer delete an event from Nextcloud with attendee, the events in Odoo would not be deleted

  1. Agenda from organizer. Deleted event from Nextcloud (meeting with Randy 1)

image

  1. After sync event is still in Odoo agenda (from organizer)

image

  1. Agenda Nextcloud attendee

image

  1. Agenda Odoo attendee

image

Do not override get_user_connection() + proposal for modules merge

In nextcloud_calendar_instance_per_user method get_user_connection() overrides the original method. Overriding is most of the times a bad practice and in this particular case, a long method is overridden just for changing one line of code.

Proposal:

  1. in nextcloud_odoo_sync isolate these few lines https://github.com/onesteinbv/addons-customer-nextcloud/blob/staging/nextcloud_odoo_sync/models/nc_sync_user.py#L197-L200 into a new separate method
  2. in nextcloud_calendar_instance_per_user remove get_user_connection() and extend the new method only.

Extra consideration:

considering how small module nextcloud_calendar_instance_per_user is, what about merging nextcloud_calendar_instance_per_user into module nextcloud_odoo_sync? The enabling/disabling of the functionality could be made configurable.

Make configuration multicompany compliant

Looking at the definition of fields in res.config.settings:

    nextcloud_url = fields.Char(string="Server URL")
    nextcloud_login = fields.Char(
        string="Login", config_parameter="nextcloud_odoo_sync.nextcloud_login"
    )
    nextcloud_password = fields.Char(
        string="Password", config_parameter="nextcloud_odoo_sync.nextcloud_password"
    )

the nextcloud_url is only stored in res.config.settings which is a transient model. So when the transient record is automatically canceled by Odoo from the database, the nextcloud_url value is lost. Proposal: add the nextcloud_url in res.company and refer to it as related field from res.config.settings.

The fields nextcloud_login and nextcloud_password are stored as config_parameter, but this way they are not multicompany compliant because config_parameter is global. Proposal: add nextcloud_login and nextcloud_password in res.company and refer to them as related field from res.config.settings.

Every time nextcloud_url, nextcloud_login and nextcloud_password are called by the user, they must be read from the actual company of the current user. In case of cron jobs, all the companies should be considered.

Make atleast one field mandatory on User Setup Page

You can save records on User Setup page without entering any data(empty records).

Additionally, clicking on get events button throws out an error as follows:
Odoo Server Error
Traceback (most recent call last):
File "/odoo15/odoo15-server/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
result = request.dispatch()
File "/odoo15/odoo15-server/odoo/http.py", line 688, in dispatch
result = self._call_function(**self.params)
File "/odoo15/odoo15-server/odoo/http.py", line 360, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/odoo15/odoo15-server/odoo/service/model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "/odoo15/odoo15-server/odoo/http.py", line 349, in checked_call
result = self.endpoint(*a, **kw)
File "/odoo15/odoo15-server/odoo/http.py", line 917, in call
return self.method(*args, **kw)
File "/odoo15/odoo15-server/odoo/http.py", line 536, in response_wrap
response = f(*args, **kw)
File "/odoo15/odoo15-server/addons/web/controllers/main.py", line 1352, in call_button
action = self._call_kw(model, method, args, kwargs)
File "/odoo15/odoo15-server/addons/web/controllers/main.py", line 1340, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/odoo15/odoo15-server/odoo/api.py", line 464, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "/odoo15/odoo15-server/odoo/api.py", line 451, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "/odoo15/custom/addons/nextcloud_odoo_sync/models/nc_sync_user.py", line 153, in get_all_user_events
events = params['all_odoo_event_ids']
Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/odoo15/odoo15-server/odoo/http.py", line 644, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/odoo15/odoo15-server/odoo/http.py", line 302, in _handle_exception
raise exception.with_traceback(None) from new_cause
KeyError: 'all_odoo_event_ids'

Issue Duplicates in Odoo

Working with version 15.0.1.1.

When syncing event from Nextcloud to Odoo with an attendee, the attendee has duplicat events in Odoo

In this case Randy 2 is the attendee (and his calendar view). Not the organizer. There is a duplicate with Randy 2 as organizer.

image

image

image

Issue change event with another attendee

When you change an event from Odoo with attendee, the event for attendee in Nextcloud would not change. Still old event.
Example: Randy 1 made an appointment on 22nd, also for attendee Randy 2. Sync goes fine. After Randy 1 change date to 23rd, change is not activated for attendee Randy 2 in Nextcloud. Here the examples:

Randy 1 changed event in Odoo to 23rd

image

After sync in Nexcloud for Randy 1 it rescheduled to 23rd

image

Odoo agenda Randy 2 is changed to 23rd

image

In Nexcloud for Randy 2 it's still 22nd

image

Issue on running sync

Received the following issue when trying to run sync:
Odoo Server Error
Traceback (most recent call last):
File "/opt/odoo/odoo-server/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
result = request.dispatch()
File "/opt/odoo/odoo-server/odoo/http.py", line 687, in dispatch
result = self._call_function(**self.params)
File "/opt/odoo/odoo-server/odoo/http.py", line 359, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/opt/odoo/odoo-server/odoo/service/model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "/opt/odoo/odoo-server/odoo/http.py", line 348, in checked_call
result = self.endpoint(*a, **kw)
File "/opt/odoo/odoo-server/odoo/http.py", line 916, in call
return self.method(*args, **kw)
File "/opt/odoo/odoo-server/odoo/http.py", line 535, in response_wrap
response = f(*args, **kw)
File "/opt/odoo/odoo-server/addons/web/controllers/main.py", line 1346, in call_button
action = self._call_kw(model, method, args, kwargs)
File "/opt/odoo/odoo-server/addons/web/controllers/main.py", line 1334, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/opt/odoo/odoo-server/odoo/api.py", line 464, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "/opt/odoo/odoo-server/odoo/api.py", line 451, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "/opt/odoo/custom/addons/addons-customer-nextcloud/nextcloud_odoo_sync/wizards/run_sync_test_wizard.py", line 13, in run_sync_cron_test
self.env["nextcloud.caldav"].sync_cron()
File "/opt/odoo/custom/addons/addons-customer-nextcloud/nextcloud_odoo_sync/models/nextcloud_caldav.py", line 1231, in sync_cron
params = self.update_odoo_events(user, od_events_dict, **params)
File "/opt/odoo/custom/addons/addons-customer-nextcloud/nextcloud_odoo_sync/models/nextcloud_caldav.py", line 689, in update_odoo_events
event_name = vals["name"]
Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/opt/odoo/odoo-server/odoo/http.py", line 643, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/opt/odoo/odoo-server/odoo/http.py", line 301, in _handle_exception
raise exception.with_traceback(None) from new_cause
KeyError: 'name'

Make use of VCR.py for offline tests

When creating automated tests for a connector module like this one (nextcloud_odoo_sync), I would suggest to avoid mocked tests (unittest.mock) for offline tests. There is a better way to write offline tests: making use of library VCR.py.

In OCA there are plenty of examples of tests written with that library, for example https://github.com/OCA/connector-magento/tree/12.0/connector_magento/tests

The idea is to write non-mocked tests, so that odoo communicates with a real running instance of nextcloud server. Once the tests are executed the first time, the data exchanged between odoo and nextcloud is recorded, so that the next time the tests are executed, the recorded data are reused without the need of another data exchange between odoo and nextcloud.

Here a simple example of how to convert tests from online to offline using VCR.py: https://github.com/OCA/l10n-netherlands/pull/309/files

Issue for first time syncing of odoo event to nextcloud

I did the user setup for my user in Odoo,created the first event in Odoo and ran the run sync functionality.Checked in nextcloud and the event was not synced in nextcloud.Then I created a event in nextcloud and then ran the run sync functionality and I was able to find both the events in Odoo and now also both the events were present in nextcloud. So, there's an issue when the event is being synced for the first time from Odoo to nextcloud.

First.time.sync.of.event.mp4

Issue change event with attendee (for organizer and attendee)

When changing event from Odoo, event is not changed in Nextvcloud for both:

  1. Organizer changed event in Odoo with attendee Randy2

image

  1. After sync there event didnt change in Nexcloud for the organizer

image

  1. For attendee also no change of the event in Nextcloud

image

Issue Sync event with attendee

When planning an event from Nextcloud incl attendee, the organiser doensn't have the event in Odoo after sync. The attendee does have both events. Example:

Randy 2 is organiser>

Nextcloud agenda event Randy 2

image

Odoo agenda event Randy 2

image

Nextcloud agenda Randy 1

image

Odoo agenda event Randy 1

image

Code Review: Unnecessary call of get_event_datetime for all types of fields

@iscale-odoo , I had mentioned this in the past as well, reiterating it here that get_event_datetime function should be called only for date/datetime fields.

Right now, its getting called for all types of fields and then as you have added in the exception handling , its logging for every field and it shows up in the logs as follows:
2023-05-02 06:29:59,998 68 WARNING nwb odoo.addons.nextcloud_odoo_sync.models.nextcloud_caldav: 'last-modified'
2023-05-02 06:29:59,998 68 WARNING nwb odoo.addons.nextcloud_odoo_sync.models.nextcloud_caldav: Unknown string format: 3a60dfb0150d877a9b32f7d33519ecc97b109e74
2023-05-02 06:29:59,999 68 WARNING nwb odoo.addons.nextcloud_odoo_sync.models.nextcloud_caldav: Unknown string format: bsp problemen verbouwing JM
2023-05-02 06:29:59,999 68 WARNING nwb odoo.addons.nextcloud_odoo_sync.models.nextcloud_caldav: Unknown string format: Vredenburchsingel
2023-05-02 06:30:00,000 68 WARNING nwb odoo.addons.nextcloud_odoo_sync.models.nextcloud_caldav: 'dtstart'
2023-05-02 06:30:00,000 68 WARNING nwb odoo.addons.nextcloud_odoo_sync.models.nextcloud_caldav: 'dtend'
2023-05-02 06:30:00,001 68 WARNING nwb odoo.addons.nextcloud_odoo_sync.models.nextcloud_caldav: Parser must be a string or character stream, not list
2023-05-02 06:30:00,450 68 WARNING nwb odoo.addons.nextcloud_odoo_sync.models.nc_sync_log: Error creating Odoo event time data '20230314T1' does not match format '%Y-%m-%d'.

Please rectify this as well while you are resolving the issue with date formats

Simplify "Nextcloud Event Status"

Model nc.event.status has only one field: name. I don't see any valid reason to have nc.event.status as a dedicated model for tracking the event status.

Proposal:

  1. remove nc.event.status model an the 3 values defined in nc_event_status_data.xml
  2. in calendar.event replace field nc_status_id of type Many2one with a field of type Selection, eg.:
nc_status = fields.Selection([("confirmed", "Confirmed"), ("tentative", "Tentative"), ("canceled", "Canceled")])

Code Review: Make nc_calendar_select as a many2one field

nc_calendar_select (in calendar.event) should be made a Many2one field and domain should be applied on it , as dynamic updation of a selection field is not supported in Odoo and I believe the list of nextcloud calendars should be updated based on the Organizer. There's also an issue in _get_nc_calendar_selection function as it's always picking up the logged in user's calendar which should not be the case

Make use of jicson as external dependency

In module nextcloud_odoo_sync the file jicson.py is actually a copy of the external python library jicson.

Proposed changes:

  1. Add jicson in the external_dependencies of the manifest
  2. Remove jicson.py file from module
  3. Update the code where the jicson is imported, eg. importing it this way:
import logging
_logger = logging.getLogger(__name__)
try:
    import jicson
except ImportError:
    _logger.debug("Cannot `import jicson`.")

Naming files, models, fields, context parameters, etc...

File naming
File nextcloud_base.py contains a definition of an AbstractModel, so the file could be named abstract_nextcloud_base.py for better readability.
Same discourse for file nextcloud_caldav.py: it could be named abstract_nextcloud_caldav.py.

Model naming
Models like nc.calendar, nc.sync.log, nc.sync.user should be renamed to nextcloud.calendar, nextcloud.sync.log, nextcloud.sync.user , so that the corresponding name of tables in database will be more explicit. It's also the same naming as it was made for abstract models: nextcloud.base and nextcloud.caldav, so the naming will be more consistent.

Definition of model calendar.event.nchash should be placed in a separate file. Also this model should be renamed consistently to the other models, for example renamed to: nextcloud.calendar.event.nchash.

Field naming
Some models are inherited from standard Odoo: calendar.event, calendar.recurrence, res.config.settings, res.partner, res.users. In those models, the naming of fields should be not conflicting with any other module that could potentially adopt the same name. Proposal is to rename the following:

  • calendar.event: all fields name prefix from nc_* to nextcloud_*
  • calendar.recurrence: field nc_exdate to nextcloud_exdate
  • res.config.settings: field enable_calendar_sync to nextcloud_enable_calendar_sync and log_capacity to nextcloud_log_capacity
  • res.partner: field nc_sync to nextcloud_sync
  • res.users: field nc_calendar_ids to nextcloud_calendar_ids

Context parameters naming
When passing parameters in context, the name of the parameter should be not conflicting with any other module that could potentially use the same name for context parameters. So for example:

  • with_context(sync=True) should become with_context(nextcloud_sync=True)
  • self._context.get("sync", False) should become self._context.get("nextcloud_sync", False)
  • and so on...

Receiving Issue while trying to do Run sync activity

Received the following error when trying to run sync activity:
RPC_ERROR
Odoo Server Error
Traceback (most recent call last):
File "/odoo15/odoo15-server/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
result = request.dispatch()
File "/odoo15/odoo15-server/odoo/http.py", line 688, in dispatch
result = self._call_function(**self.params)
File "/odoo15/odoo15-server/odoo/http.py", line 360, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/odoo15/odoo15-server/odoo/service/model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "/odoo15/odoo15-server/odoo/http.py", line 349, in checked_call
result = self.endpoint(*a, **kw)
File "/odoo15/odoo15-server/odoo/http.py", line 917, in call
return self.method(*args, **kw)
File "/odoo15/odoo15-server/odoo/http.py", line 536, in response_wrap
response = f(*args, **kw)
File "/odoo15/odoo15-server/addons/web/controllers/main.py", line 1352, in call_button
action = self._call_kw(model, method, args, kwargs)
File "/odoo15/odoo15-server/addons/web/controllers/main.py", line 1340, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/odoo15/odoo15-server/odoo/api.py", line 464, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "/odoo15/odoo15-server/odoo/api.py", line 451, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "/odoo15/custom/addons/nextcloud_odoo_sync/wizard/run_sync_test_wizard.py", line 14, in run_sync_cron_test
self.env['nextcloud.caldav'].sync_cron()
File "/odoo15/custom/addons/nextcloud_odoo_sync/models/nextcloud_caldav.py", line 780, in sync_cron
od_events_dict, nc_events_dict = self.compare_events(od_events, nc_events)
File "/odoo15/custom/addons/nextcloud_odoo_sync/models/nextcloud_caldav.py", line 69, in compare_events
if ode['od_event'].nc_status.name.lower() != 'canceled':
Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/odoo15/odoo15-server/odoo/http.py", line 644, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/odoo15/odoo15-server/odoo/http.py", line 302, in _handle_exception
raise exception.with_traceback(None) from new_cause
AttributeError: 'bool' object has no attribute 'lower'

Issue recurring

When you want to use recurring events, the following error will apply:

RPC_ERROR
Odoo Server Error
Traceback (most recent call last):
File "/opt/odoo/odoo-server/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
result = request.dispatch()
File "/opt/odoo/odoo-server/odoo/http.py", line 687, in dispatch
result = self._call_function(**self.params)
File "/opt/odoo/odoo-server/odoo/http.py", line 359, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/opt/odoo/odoo-server/odoo/service/model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "/opt/odoo/odoo-server/odoo/http.py", line 348, in checked_call
result = self.endpoint(*a, **kw)
File "/opt/odoo/odoo-server/odoo/http.py", line 916, in call
return self.method(*args, **kw)
File "/opt/odoo/odoo-server/odoo/http.py", line 535, in response_wrap
response = f(args, **kw)
File "/opt/odoo/odoo-server/addons/web/controllers/main.py", line 1342, in call_kw
return self._call_kw(model, method, args, kwargs)
File "/opt/odoo/odoo-server/addons/web/controllers/main.py", line 1334, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/opt/odoo/odoo-server/odoo/api.py", line 462, in call_kw
result = _call_kw_model_create(method, model, args, kwargs)
File "/opt/odoo/odoo-server/odoo/api.py", line 442, in _call_kw_model_create
result = method(recs, args, **kwargs)
File "", line 2, in create
File "/opt/odoo/odoo-server/odoo/api.py", line 391, in _model_create_single
return create(self, arg)
File "/opt/odoo/custom/addons/addons-customer-nextcloud/nextcloud_odoo_sync/models/calendar_event.py", line 168, in create
res = super(CalendarEvent, self).create(vals)
File "", line 2, in create
File "/opt/odoo/odoo-server/odoo/api.py", line 412, in _model_create_multi
return create(self, [arg])
File "/opt/odoo/odoo-server/addons/google_calendar/models/calendar.py", line 45, in create
return super(Meeting, self.with_context(dont_notify=notify_context)).create([
File "", line 2, in create
File "/opt/odoo/odoo-server/odoo/api.py", line 413, in _model_create_multi
return create(self, arg)
File "/opt/odoo/odoo-server/addons/calendar/models/calendar_event.py", line 422, in create
detached_events = event._apply_recurrence_values(recurrence_values)
File "/opt/odoo/odoo-server/addons/calendar/models/calendar_event.py", line 803, in _apply_recurrence_values
return to_update._apply_recurrence()
File "/opt/odoo/odoo-server/addons/google_calendar/models/calendar_recurrence_rule.py", line 18, in _apply_recurrence
detached_events = super()._apply_recurrence(specific_values_creation, no_send_edit,
File "/opt/odoo/odoo-server/addons/calendar/models/calendar_recurrence.py", line 242, in _apply_recurrence
self.env['calendar.event'].with_context(no_mail_to_attendees=True, mail_create_nolog=True).create(event_vals)
File "", line 2, in create
File "/opt/odoo/odoo-server/odoo/api.py", line 394, in _model_create_single
return self.browse().concat(
(create(self, vals) for vals in arg))
File "/opt/odoo/odoo-server/odoo/api.py", line 394, in
return self.browse().concat(
(create(self, vals) for vals in arg))
File "/opt/odoo/custom/addons/addons-customer-nextcloud/nextcloud_odoo_sync/models/calendar_event.py", line 168, in create
res = super(CalendarEvent, self).create(vals)
File "", line 2, in create
File "/opt/odoo/odoo-server/odoo/api.py", line 412, in _model_create_multi
return create(self, [arg])
File "/opt/odoo/odoo-server/addons/google_calendar/models/calendar.py", line 45, in create
return super(Meeting, self.with_context(dont_notify=notify_context)).create([
File "", line 2, in create
File "/opt/odoo/odoo-server/odoo/api.py", line 413, in _model_create_multi
return create(self, arg)
File "/opt/odoo/odoo-server/addons/calendar/models/calendar_event.py", line 416, in create
recurring_events = super().create(recurring_vals)
File "", line 2, in create
File "/opt/odoo/odoo-server/odoo/api.py", line 413, in _model_create_multi
return create(self, arg)
File "/opt/odoo/odoo-server/addons/mail/models/mail_thread.py", line 265, in create
threads = super(MailThread, self).create(vals_list)
File "", line 2, in create
File "/opt/odoo/odoo-server/odoo/api.py", line 413, in _model_create_multi
return create(self, arg)
File "/opt/odoo/odoo-server/addons/google_calendar/models/google_sync.py", line 85, in create
records = super().create(vals_list)
File "", line 2, in create
File "/opt/odoo/odoo-server/odoo/api.py", line 413, in _model_create_multi
return create(self, arg)
File "/opt/odoo/odoo-server/odoo/addons/base/models/ir_fields.py", line 613, in create
recs = super().create(vals_list)
File "", line 2, in create
File "/opt/odoo/odoo-server/odoo/api.py", line 413, in _model_create_multi
return create(self, arg)
File "/opt/odoo/odoo-server/odoo/models.py", line 4079, in create
records = self._create(data_list)
File "/opt/odoo/odoo-server/odoo/models.py", line 4143, in _create
col_val = field.convert_to_column(val, self, stored)
File "/opt/odoo/odoo-server/odoo/fields.py", line 2530, in convert_to_column
value = self.convert_to_cache(value, record)
File "/opt/odoo/odoo-server/odoo/fields.py", line 2542, in convert_to_cache
raise ValueError("Wrong value for %s: %r" % (self, value))
Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/opt/odoo/odoo-server/odoo/http.py", line 643, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/opt/odoo/odoo-server/odoo/http.py", line 301, in _handle_exception
raise exception.with_traceback(None) from new_cause
ValueError: Wrong value for calendar.event.nc_calendar_select: '110'

Code Review: Deletion of records through data files

Can you please let us know why the following records were deleted through the data file:
1.calendar.alarm_mail_1
2.calendar.alarm_mail_2

3.calendar.categ_meet1
4.calendar.categ_meet2
5.calendar.categ_meet3
6.calendar.categ_meet4
7.calendar.categ_meet5

As these can still be used with events other than the ones you are syncing to Nextcloud (if at all it is causing any issues with nextcloud sync).

Code review from previous meeting: 2023-03-17

  1. Removed unused functions (_compute_nc_calendar_ids())
  2. onchange_nc_user_ids() should be able to handle False value and clear the content of calendar_ids for the current user
    • determine which is being called first, the "compute" function with field dependency or the "onchange" event
    • depending on the result, remove unnecessary checks for field value if already done by the other function
  3. log_event() function has "res" variable not properly defined
  4. Refactor compute_user_has_calendar() to reduce lines
  5. Add the "user_name" as part of the constraints dependency for function check_user_exist()
  6. get_users() function needs to be refactored to make use of the "params" variable passed
  7. compare_events() function has "od_event" variable not declared properly or being checked for value
  8. In res_config_settings.py, refactor to move the setting of values to field parameters (new API) instead of using set_values method (old API)
  9. The wizard run_sync_test_wizard.py should be renamed and dropped the "test" word since it is not used for testing the module
    • remove the "message" field and hard code the value in the XML form instead

Nextcloud page in events should not be visible

The Nextcloud page(Notebook) in calendar events is always visible, it should be visible for events to be synced with nextcloud and readonly, visibility and other parameters should be set respectively on the fields in this page for eg.: Synced field is editable, so the user can create an event and set it to true , in that case, the event would not get created in nextcloud

Issue sync with another attendee

After start event from Odoo with attendee and syncing, the event in Odoo is deleted for the organizer. Attendee does no event in Odoo. Both have the events in Nextcloud.

image

image

image

image

Issue with incorrect url in configuration

While doing the configuration from configuration->settings->Nextcloud and enter an incorrect url(you can try - https://next-odoo.onestein.eu/), we get not found error as follows:
RPC_ERROR
Odoo Server Error
Traceback (most recent call last):
File "/odoo15/odoo15-server/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
result = request.dispatch()
File "/odoo15/odoo15-server/odoo/http.py", line 687, in dispatch
result = self._call_function(**self.params)
File "/odoo15/odoo15-server/odoo/http.py", line 359, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/odoo15/odoo15-server/odoo/service/model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "/odoo15/odoo15-server/odoo/http.py", line 348, in checked_call
result = self.endpoint(*a, **kw)
File "/odoo15/odoo15-server/odoo/http.py", line 910, in call
return self.method(*args, **kw)
File "/odoo15/odoo15-server/odoo/http.py", line 535, in response_wrap
response = f(*args, **kw)
File "/odoo15/odoo15-server/addons/web/controllers/main.py", line 1330, in call_button
action = self._call_kw(model, method, args, kwargs)
File "/odoo15/odoo15-server/addons/web/controllers/main.py", line 1318, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/odoo15/odoo15-server/odoo/api.py", line 464, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "/odoo15/odoo15-server/odoo/api.py", line 451, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "/odoo15/odoo15-server/odoo/addons/base/models/res_config.py", line 624, in execute
self.set_values()
File "/odoo15/odoo15-server/addons/sale_management/models/res_config_settings.py", line 28, in set_values
return super(ResConfigSettings, self).set_values()
File "/odoo15/odoo15-server/addons/sale/models/res_config_settings.py", line 75, in set_values
super(ResConfigSettings, self).set_values()
File "/odoo15/odoo15-server/addons/account/models/res_config_settings.py", line 148, in set_values
super(ResConfigSettings, self).set_values()
File "/odoo15/custom/addons/addons-customer-nextcloud/nextcloud_odoo_sync/models/res_config_settings.py", line 37, in set_values
connection, principal = self.env[
File "/odoo15/custom/addons/addons-customer-nextcloud/nextcloud_odoo_sync/models/nextcloud_caldav.py", line 1372, in check_nextcloud_connection
return client, client.principal()
File "/home/anjeelharia/.local/lib/python3.8/site-packages/caldav/davclient.py", line 411, in principal
self._principal = Principal(client=self, *largs, **kwargs)
File "/home/anjeelharia/.local/lib/python3.8/site-packages/caldav/objects.py", line 480, in init
cup = self.get_property(dav.CurrentUserPrincipal())
File "/home/anjeelharia/.local/lib/python3.8/site-packages/caldav/objects.py", line 210, in get_property
foo = self.get_properties([prop], **passthrough)
File "/home/anjeelharia/.local/lib/python3.8/site-packages/caldav/objects.py", line 235, in get_properties
response = self._query_properties(props, depth)
File "/home/anjeelharia/.local/lib/python3.8/site-packages/caldav/objects.py", line 171, in _query_properties
return self._query(root, depth)
File "/home/anjeelharia/.local/lib/python3.8/site-packages/caldav/objects.py", line 198, in _query
raise error.NotFoundError(errmsg(ret))
Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/odoo15/odoo15-server/odoo/http.py", line 643, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/odoo15/odoo15-server/odoo/http.py", line 301, in _handle_exception
raise exception.with_traceback(None) from new_cause
caldav.lib.error.NotFoundError: NotFoundError at '404 NOT FOUND

b'\n \n \n \n \n \n \n <title>Odoo</title>\n \n \n \n \n <script id="web.layout.odooscript" type="text/javascript">\n var odoo = {\n csrf_token: "66c011ae7813ecf2eec31863c66de5a31a8415c0o1713616124",\n debug: "",\n };\n </script>\n <script type="text/javascript">\n odoo.session_info = {"is_admin": false, "is_system": false, "is_website_user": false, "user_id": false, "is_frontend": true, "profile_session": null, "profile_collectors": null, "profile_params": null, "show_effect": "True", "translationURL": "/website/translations", "cache_hashes": {"translations": "63c39b9719623b23090242bff39258f3aa29fe2b"}};\n if (!/(^|;\s)tz=/.test(document.cookie)) {\n const userTZ = Intl.DateTimeFormat().resolvedOptions().timeZone;\n document.cookie = tz=${userTZ}; path=/;\n }\n </script>\n <script defer="defer" type="text/javascript" src="/web/assets/19-53003c2/web.assets_common_minimal.min.js" data-asset-bundle="web.assets_common_minimal" data-asset-version="53003c2"></script>\n <script defer="defer" type="text/javascript" src="/web/assets/20-7af32e4/web.assets_frontend_minimal.min.js" data-asset-bundle="web.assets_frontend_minimal" data-asset-version="7af32e4"></script>\n <script defer="defer" type="text/javascript" data-src="/web/assets/120-8608b65/web.assets_common_lazy.min.js" data-asset-bundle="web.assets_common_lazy" data-asset-version="8608b65"></script>\n <script defer="defer" type="text/javascript" data-src="/web/assets/121-ae402b1/web.assets_frontend_lazy.min.js" data-asset-bundle="web.assets_frontend_lazy" data-asset-version="ae402b1"></script>\n \n \n

\n \n \n
\n \n Logo of My Company\n \n \n
\n \n \n \n
\n
\n
\n
\n
\n
\n \n
\n
\n

Error 404

\n

We couldn't find the page you're looking for!

\n

\n

Don't panic. If you think it's our mistake, please send us a message on this page.

\n
\n
\n
\n
\n
\n
\n
\n

Maybe you were looking for one of these popular pages?

\n \n
\n
\n
\n
\n
\n
\n \n \n \n
\n
\n
\n
\n Copyright © My Company\n
\n
\n
\n Powered by \n \n Odoo\n \n
\n
\n
\n
\n
\n \n
\n \n '', reason no reason

Deleting all Odoo events gives error

Deleting all Odoo events gives error

image

RPC_ERROR
Odoo Server Error
Traceback (most recent call last):
File "/opt/odoo/odoo-server/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
result = request.dispatch()
File "/opt/odoo/odoo-server/odoo/http.py", line 687, in dispatch
result = self._call_function(**self.params)
File "/opt/odoo/odoo-server/odoo/http.py", line 359, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/opt/odoo/odoo-server/odoo/service/model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "/opt/odoo/odoo-server/odoo/http.py", line 348, in checked_call
result = self.endpoint(*a, **kw)
File "/opt/odoo/odoo-server/odoo/http.py", line 916, in call
return self.method(*args, **kw)
File "/opt/odoo/odoo-server/odoo/http.py", line 535, in response_wrap
response = f(*args, **kw)
File "/opt/odoo/odoo-server/addons/web/controllers/main.py", line 1346, in call_button
action = self._call_kw(model, method, args, kwargs)
File "/opt/odoo/odoo-server/addons/web/controllers/main.py", line 1334, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/opt/odoo/odoo-server/odoo/api.py", line 464, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "/opt/odoo/odoo-server/odoo/api.py", line 451, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "/opt/odoo/custom/addons/addons-customer-nextcloud/v_nextcloud/models/nextcloud.py", line 227, in delete_all_odoo_events
rec.env['nc.sync.user'].search([]).write({'user_events_hash': False})
File "/opt/odoo/custom/addons/addons-customer-nextcloud/nextcloud_odoo_sync/models/nc_sync_user.py", line 123, in write
return super(NcSyncUser, self).write(vals)
File "/opt/odoo/odoo-server/odoo/models.py", line 3798, in write
raise ValueError("Invalid field %r on model %r" % (fname, self._name))
Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/opt/odoo/odoo-server/odoo/http.py", line 643, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/opt/odoo/odoo-server/odoo/http.py", line 301, in _handle_exception
raise exception.with_traceback(None) from new_cause
ValueError: Invalid field 'user_events_hash' on model 'nc.sync.user'

Getting error if you change the organizer of an event in Odoo

Steps to reproduce:
1.Create an event in odoo
2.When you try to change the organizer , it would throw out the following error

RPC_ERROR
Odoo Server Error
Traceback (most recent call last):
File "/opt/odoo/odoo-server/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
result = request.dispatch()
File "/opt/odoo/odoo-server/odoo/http.py", line 687, in dispatch
result = self._call_function(**self.params)
File "/opt/odoo/odoo-server/odoo/http.py", line 359, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/opt/odoo/odoo-server/odoo/service/model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "/opt/odoo/odoo-server/odoo/http.py", line 348, in checked_call
result = self.endpoint(*a, **kw)
File "/opt/odoo/odoo-server/odoo/http.py", line 916, in call
return self.method(*args, **kw)
File "/opt/odoo/odoo-server/odoo/http.py", line 535, in response_wrap
response = f(*args, **kw)
File "/opt/odoo/odoo-server/addons/web/controllers/main.py", line 1342, in call_kw
return self._call_kw(model, method, args, kwargs)
File "/opt/odoo/odoo-server/addons/web/controllers/main.py", line 1334, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/opt/odoo/odoo-server/odoo/api.py", line 464, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "/opt/odoo/odoo-server/odoo/api.py", line 451, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "/opt/odoo/odoo-server/odoo/models.py", line 6489, in onchange
record._onchange_eval(name, field_onchange[name], result)
File "/opt/odoo/odoo-server/odoo/models.py", line 6222, in _onchange_eval
method_res = method(self)
File "/opt/odoo/custom/addons/nextcloud_odoo_sync/models/calendar_event.py", line 94, in onchange_nc_user_id
self.nc_calendar_select = default_calendar_id.id
File "/opt/odoo/odoo-server/odoo/fields.py", line 1209, in set
self.write(new_records, value)
File "/opt/odoo/odoo-server/odoo/fields.py", line 1019, in write
cache_value = self.convert_to_cache(value, records)
File "/opt/odoo/odoo-server/odoo/fields.py", line 2542, in convert_to_cache
raise ValueError("Wrong value for %s: %r" % (self, value))
Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/opt/odoo/odoo-server/odoo/http.py", line 643, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/opt/odoo/odoo-server/odoo/http.py", line 301, in _handle_exception
raise exception.with_traceback(None) from new_cause
ValueError: Wrong value for calendar.event.nc_calendar_select: 11

Error when running Sync Activity 20230308-101540

In sync logs we found two errors:

  1. Error updating Nextcloud event "Test NextCLoud" for user "Anjeel Haria": 'VEVENT components cannot contain more than 1 ORGANIZER'
    --

  2. Error saving event "Sales meeting" for user "Randy Charleston":
    PutError at '404 Not Found

b'\n<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">\n <s:exception>Sabre\DAV\Exception\NotFound</s:exception>\n <s:message>Node with name '22370806-6944-4DB4-8A4D-AE585D7EF174.ics' could not be found</s:message>\n</d:error>\n'', reason no reason

Sync Activity generating high data volume - log rotation is missing

The Sync Activity is creating a huge number of records.
Two days of testing with a few calendars by tow users primarily, has created more than 20K activity records.

We need a possibility to purge such records every week or make it as a setting parameter. Else we will possibly end up with a very heavy database.

Screenshot from 2023-04-14 10-29-33

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.