Commit Graph
50 Commits
Author SHA1 Message Date
Gabriel de Paula Felix (gdpf) 69d23262f8 [IMP] microsoft_calendar: Credentials module and don't sync old events
Before this commit, when the first synchronization with Outlook Calendar was done or when the synchronization was restarted, all events previously created in Odoo (before synchronizing) were being synced with Outlook, triggering lots of emails and notifications for attendees. Additionaly, all microsoft credentials information were concentrated within the res_users file, difficulting updates in this file.

After this commit, only events created or updated after the synchronization starts (or restarts) are synced with Outlook Calendar, with 5 minutes of time acceptance for avoiding network delay issues. Moreover, a Microsoft Credentials module was added for gathering microsoft credentials in one place.

closes odoo/odoo#128150

Task-id: 3410651
Related: odoo/upgrade#5047
Signed-off-by: Arnaud Joset (arj) <arj@odoo.com>
2023-09-12 20:52:14 +00:00
Gabriel de Paula Felix (gdpf) a14bc16647 [FIX] microsoft_calendar: traceback trying to delete recurrence
Before this commit, trying to delete a recurrent event that was already synced with Google Calendar or Microsoft Calendar was raising a traceback and not showing the User Error which forbids this action to be done.

After this commit, the traceback is not shown anymore and the User Error is correctly presented to the user while trying to delete a recurrent event (with Microsoft synchronization active).

Traceback snippet:

result = _call_kw_multi(method, model, args, kwargs)
File '/data/build/odoo/odoo/api.py', line 448, in _call_kw_multi
  result = method(recs, *args, **kwargs)
File '/data/build/odoo/addons/microsoft_calendar/models/calendar.py', line 168, in action_mass_archive
  if self._check_microsoft_sync_status() and any(self.microsoft_id):
TypeError: 'bool' object is not iterable

The above server error caused the following client error:
RPC_ERROR: Odoo Server Error

closes odoo/odoo#134293

Issue: 3468190
Task-id: 3473180
Signed-off-by: Arnaud Joset (arj) <arj@odoo.com>
Signed-off-by: Gabriel de Paula Felix (gdpf) <gdpf@odoo.com>
2023-09-06 05:53:42 +00:00
Gabriel de Paula Felix (gdpf) 07f17b0c80 [FIX] microsoft_calendar: traceback restarting synchronizations
Before this commit, when restarting a synchronization with Outlook or Google, a traceback error could be thrown due when accessing a variable possibly null. After this commit, the variable integrity is checked before its access.

Issue from: 3473180

closes odoo/odoo#134181

X-original-commit: e7015b6c0cd2bd009184bfbc69730c211922658b
Signed-off-by: Arnaud Joset (arj) <arj@odoo.com>
Signed-off-by: Gabriel de Paula Felix (gdpf) <gdpf@odoo.com>
2023-09-04 19:58:31 +00:00
Gabriel de Paula Felix (gdpf) a395277fed [IMP] microsoft_calendar: add synchronization pause button and tests
Configuration and tests added for 'pause synchronization' button (Outlook module).

closes odoo/odoo#126560

Task-id: 3290898
Signed-off-by: Arnaud Joset (arj) <arj@odoo.com>
2023-08-21 12:38:44 +02:00
Gabriel de Paula Felix (gdpf) 29ce2f0451 [FIX] microsoft_calendar: no sync for recurrent events
Before this commit, updating recurring events was troublesome due to an Outlook limitation, which was sending spam to attendees. After this commit, when updating recurring events, it is suggested for users to update recurrences directly in Outlook Calendar to handle this limitation. It is not allowed anymore creating recurrences in Odoo when the sync with Outlook is active (although recurrences created in Outlook are still synchronized in Odoo). Recurrent events that were created before the synchronization start (which are not synced) can still be deleted in Odoo (then a suggestion of recreating them in Outlook is shown).

Previous unit tests regarding the synchronization of recurrences from Odoo to Outlook were deactivated. New tests were added asserting the forbiddance of this recurrence creation and update flow.

closes odoo/odoo#131806

Task-id: 3204905
X-original-commit: 27ee51029c1d4e9164b9705306b59b26598bcf7e
Signed-off-by: Arnaud Joset (arj) <arj@odoo.com>
Signed-off-by: Gabriel de Paula Felix (gdpf) <gdpf@odoo.com>
2023-08-11 22:50:24 +02:00
Xavier-Do 402e5d0acb [FIX] microsoft_calendar: remove unused _from_uids
Part-of: odoo/odoo#119813
2023-07-18 11:42:26 +02:00
Gabriel de Paula Felix (gdpf) 9b5070576e [IMP] microsoft_calendar: test checking single recurrent event deletion
Added a test asserting the correct functionality of single events deletion.

closes odoo/odoo#127980

X-original-commit: d93d564022bcdafece33f11f578013420b106b64
Signed-off-by: Arnaud Joset (arj) <arj@odoo.com>
2023-07-17 18:13:16 +02:00
pedrambiria 033f0f915e [FIX] microsoft_calendar: delete events correctly when reseting account
Before this commit, if you reset your microsoft callendar account and
set to remove events from Odoo, it won't remove them. The problem is
that the ('ms_universal_event_id', '!=', False) condition is not
implemented, and it can't remove the existing events.

opw-3382445

closes odoo/odoo#126739

X-original-commit: c4d8530c51e48e1f7c264b2b0c1efdab8d1fe0e6
Signed-off-by: Arnaud Joset (arj) <arj@odoo.com>
Signed-off-by: Pedram Bi Ria (pebr) <pebr@odoo.com>
2023-06-28 23:02:37 +02:00
Louis Wicket (wil) 9afe7c74c9 [IMP] *: remove "French spacing" 👺
According to Wiktionary, French spacing is "the archaic practice (though
still current in French) of inserting a space around colons, semicolons,
question marks, and exclamation marks". This is not standard practice in
English and most languages of the world.

The purpose of this commit is to start purging the code from this typo,
as it may reflect poorly on the software for some people.

closes odoo/odoo#114533

Related: odoo/enterprise#37853
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-03-14 15:52:10 +01:00
pedrambiria 60845c8d73 [FIX] microsoft_calendar: prevent spamming after syncing the 2nd user
Before this commit: If the Odoo database is shared amongst multiple
users, and another user wants to sync their Outlook calendar with Odoo
Calendar, Outlook will again pull the existing Odoo Calendar events
during the sync and treat them as new events, causing Outlook to send
email invitations to all event attendees.

Steps to reproduce the issue:
 1. Create two users in Odoo
 2. Create two outlook accounts
 3. Change the email of Odoo's users to the same as the outlook accounts
 4. Create some shared events with the second user on the first
    outlook calendar and vice versa
 5. Sync the first user's calendar with Outlook
 6. When the events are fetched to the Odoo, sync the second user
   => emails send to the attendees

The solution is to exclude synced events from the first synchronization.

opw-2929673

closes odoo/odoo#112931

X-original-commit: 86862f2527341247b75df155de16b09d44a7eee6
Signed-off-by: Pedram Bi Ria (pebr) <pebr@odoo.com>
2023-02-17 11:01:42 +01:00
Ivan Yelizariev 153fe67f46 [FIX] microsoft_calendar: avoid errors on events without user_id
Field `user_id` of `event.event` is not required

https://github.com/odoo/odoo/blob/6b101d5ff0ad78b9ae2ad312f362c2224e7af457/addons/event/models/event_event.py#L119-L121

---

So, `ensure_one` might raise an error in `_microsoft_patch  >
microsoft_calendar_token > _get_microsoft_calendar_token`

https://github.com/odoo/odoo/blob/6b101d5ff0ad78b9ae2ad312f362c2224e7af457/addons/microsoft_calendar/models/microsoft_sync.py#L404-L420

https://github.com/odoo/odoo/blob/6b101d5ff0ad78b9ae2ad312f362c2224e7af457/addons/microsoft_calendar/models/microsoft_sync.py#L51-L53

https://github.com/odoo/odoo/blob/6b101d5ff0ad78b9ae2ad312f362c2224e7af457/addons/microsoft_calendar/models/res_users.py#L35-L39

---

`_microsoft_patch` is used for syncing Odoo data with Outlook calendar

https://github.com/odoo/odoo/blob/6b101d5ff0ad78b9ae2ad312f362c2224e7af457/addons/microsoft_calendar/models/calendar_attendee.py#L23-L51

https://github.com/odoo/odoo/blob/6b101d5ff0ad78b9ae2ad312f362c2224e7af457/addons/microsoft_calendar/models/microsoft_sync.py#L96

https://github.com/odoo/odoo/blob/6b101d5ff0ad78b9ae2ad312f362c2224e7af457/addons/microsoft_calendar/models/microsoft_sync.py#L204

---

Ignoring such an error seems fine, because `_microsoft_patch` is used after
commiting the changes to database anyway

https://github.com/odoo/odoo/blob/6b101d5ff0ad78b9ae2ad312f362c2224e7af457/addons/microsoft_calendar/models/microsoft_sync.py#L24-L49

---

closes odoo/odoo#111587

Ref: https://sentry.io/organizations/online/issues/3907527262/
X-original-commit: 68c5e649af67b8dc1f9c2470356b72011b32e393
Signed-off-by: Adrien Widart <awt@odoo.com>
Signed-off-by: Ivan Elizaryev (iel) <iel@odoo.com>
2023-02-03 01:13:39 +01:00
Rémy Baranx (bar) e00622efee [FIX] microsoft_calendar: cancelled event without Odoo organizer
When an event is created in Outlook by an Outlook user (user A) who does not
exist in Odoo but who invites an Odoo user (user B) who syncs his calendar with
his Outlook calendar, the event will appear in the user B Odoo calendar.

If user A cancels this event in Outlook, then when user B syncs his Odoo calendar,
the event must be removed.

closes odoo/odoo#87844

Task-id: 2746046
X-original-commit: f54a56a91e75e3de8b54a7c6c76164929a11a431
Signed-off-by: Arnaud Joset <arj@odoo.com>
2022-09-21 18:02:38 +02:00
Rémy Baranx (bar) 77e89e893c [FIX] microsoft_calendar: issue when archiving several events
In the `write` method, accessing the `ms_organizer_event_id` field of
`self` leads to an exception if `self` represents several records.

So, the idea of this fix is to set the `need_sync_m` field of all modified
records to `True` when at least a field to sync with Outlook is modified
(see `_get_microsoft_synced_fields()`) and then, at the end of the `write`
method, really patch or delete records that are already linked to Outlook
(that means they already have their `ms_organizer_event_id` field set).

closes odoo/odoo#96761

X-original-commit: 1a66343327f9ea9f59ba25ea63e26331cabb65b5
Signed-off-by: Arnaud Joset <arj@odoo.com>
2022-07-27 19:20:15 +02:00
Rémy Baranx (bar) 2fbfbf0dce [FIX] calendar, microsoft_calendar: backport bugfixes from master
As several customers complained about lot of bugs in microsoft_calendar in 14.0,
It has been decided to backport bug fixes of the model layer from master to 14.0,
without the need of an upgrade script (no new field, ...).

In master, we use 2 ids (organizer event id + universal id) instead of only one,
to handle Odoo <-> Outlook sync correctly when several attendees sync their Outlook
calendar with their Odoo calendar. For that, we have added a new field.
To report this bug fix in 14.0, the existing field which stores the organizer event id,
is now a string storing both ids separated by a ':' as follow: 'organizer_event_id:universal_id'.

2 new compute fields have been added to be able to use these 2 ids more easily.

(all commits from the original PR have been squashed to ease forward-port)

closes odoo/odoo#95736

X-original-commit: 5e83318a7240585371efd31e407829793f3e732f
Signed-off-by: Arnaud Joset <arj@odoo.com>
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2022-07-12 13:21:27 +02:00
Rémy Baranx (bar) 90480ce2d1 [IMP] microsoft_calendar: get videocall URL from a Outlook event
Basically, a Outlook event may contain a videocall URL in 2 different ways:

1) the event location may be a specific URL (such as `https://teams.microsoft.com/...`).
 In this case, we use it as `videocall_location` instead of classic `location`.
We use a list of patterns to identify these specific URLs among classic locations.

2) the event may have an attribute `isOnlineMeeting` set to `True` and
the attribute `onlineMeetingUrl` set with the URL. In this case, we use
this `onlineMeetingUrl` as `videocall_location`.

opw-2601669

closes odoo/odoo#74785

Signed-off-by: Arnaud Joset <arj@odoo.com>
2022-07-11 13:48:40 +02:00
pedrambiria fb6b959fef [FIX] microsoft_calendar: sync events without body property
Before this commit: if a Microsoft event didn't have body property,
it couldn't get synced with Odoo and raised an error.

The solution is first to check if it contains the body and then gets
its content value.

opw-2765443

closes odoo/odoo#89634

X-original-commit: 13d57ff5e714bee96fb930c1b8050816bf22c268
Signed-off-by: Arnaud Joset <arj@odoo.com>
Signed-off-by: Pedram Bi Ria (pebr) <pebr@odoo.com>
2022-05-09 12:57:42 +02:00
Florian Damhaut d9f16de7bb [FIX] microsoft_calendar: Send html description to outlook
Step to reproduce:
- Create a with a link in the decription
- Edit + Save multiple times

Current behaviour :
- Since c2b545fd8d91b7d24380ada07adee02f24623ecf we fetch the full
description with html tags which are rendered via the
- When we resend this message to outlook, the description
 will be updated via html2plaintext.
 In the case of URL, they will be added as a footnote and thus
 duplicated if the url is it's own name

Behaviour after thr PR:
- We could then also send the description with the html tags to
ensure full compatibility between the description
- Using html2plaintext update the descrtiption to markdown, with some
issues, since html is now supported in the odoo editor, using
html on both end will remove the need to use html2plaintext and
the descriptions changes stemming from it.

opw-2746358

closes odoo/odoo#87411

X-original-commit: 4c3b69a30d5724dfef2b179ac8eaeecb8ff3da42
Signed-off-by: Arnaud Joset <arj@odoo.com>
Signed-off-by: Damhaut Florian (flda) <flda@odoo.com>
2022-03-29 10:56:36 +02:00
pedrambiria 2a13a4088b [FIX] microsoft_calendar: add 'none' state to attendee state convertor
Before this commit, the 'none' state was not considered as a possible
attendee state for the microsoft, and it created an empty field in
Odoo.

This commit maps the 'none' state to the 'needsAction', based on the
microsoft documentation.

opw-2694644

closes odoo/odoo#85367

X-original-commit: 1fbd14728980bfabc466efeb437f9f7ce105dfac
Signed-off-by: Arnaud Joset <arj@odoo.com>
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2022-02-28 12:55:59 +00:00
Florian Damhaut ab43fab05a [FIX] microsoft_calendar: fetch full description
Step to reproduce:
- Create a event in outlook with a long description
- Load the event in Odoo

Current Behaviour:
- Odoo use the body preview to get the event description
If the body is longer then, the description in Odoo is incomplete.

Behaviour after PR:
- Change fetch option to get description as text
- Use body['content']  as description which is the full body.

opw-2746358

closes odoo/odoo#84362

X-original-commit: c2b545fd8d91b7d24380ada07adee02f24623ecf
Signed-off-by: Arnaud Joset <arj@odoo.com>
2022-02-10 16:35:40 +00:00
Yolann Sabauxandandro19951 e10ae3f024 [FIX] google_calendar, microsoft_calendar: ignore no partner created
Description of the issue/feature this PR addresses: in version 15,
sometimes Google and Microsoft calendar synchronizations break with error:

Create/update: a mandatory field is not set.
Delete: another model requires the record being deleted. If possible, archive it instead.
Model: Calendar Attendee Information (calendar.attendee), Field: Contact (partner_id)

This is happening, because when Odoo is syncing an event, it will match
attendee with res.partner, if no existing partner is found, a new one
will be created unless:

- the address matches an existing mail alias ([alias_name]@[mail.catchall.domain])
- the address is invalid (eg. in outlook the email address is sometimes
  in the form /o=ExchangeLabs/ou=.../cn=Recipients/cn=...

In this case we should not try to add the attendee to the odoo event.

Current behavior before PR: Error when syncing that the customer can
only solve by removing the erroneous attendee or remove the event from
their calendar.

Desired behavior after PR is merged: if the partner cannot be created
we ignore it.

opw-2670002
opw-2683889
opw-2702661
opw-2704631
opw-2711907
opw-2720032
opw-2722028
closes #82109
fixes #78678

closes odoo/odoo#82667

X-original-commit: 1cd470c8922119d0da0b69ab7d4b4ff746533689
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Signed-off-by: yosa-odoo <yosa@odoo.com>
Co-authored-by: andro19951 <andro19951@gmail.com>
2022-01-17 08:38:45 +00:00
Rémy Baranx (bar) 5716f6fabf [FIX] microsoft_calendar: do not call Outlook API during sync
When we are syncing Outlook events with Odoo events, there is no need
to call back the Outlook API to patch/delete some events.

closes odoo/odoo#80404

X-original-commit: c0094ec99e5fc24b650a257d4792f4be8b09a661
Signed-off-by: Arnaud Joset <arj@odoo.com>
2021-11-25 15:19:49 +00:00
Kevin Baptiste b90ee11ef3 [FIX] hr_holidays, *_calendar: disable sync on new leave
On large databases, the `postcommit` hook for Google|Microsoft Calendar
was taking up to 10% of a leave validation even if the user has the sync
disabled.

This commit disables the postcommit hook for new leaves, as the event will
be synced through the cron eventually.

closes odoo/odoo#80160

Taskid: 2693265
X-original-commit: 88884292e105eab2c36b2a334c617ac4978fa79c
Signed-off-by: Arnaud Joset <arj@odoo.com>
Signed-off-by: Kevin Baptiste <kba@odoo.com>
2021-11-22 11:56:46 +00:00
Florian Damhaut fb6525f82d [FIX] microsoft_calendar : Only sync-write on existing element
In case of m event being removed by a change in recurrence further change is then only applied on the existing events and not all past events

closes odoo/odoo#79889

X-original-commit: 067d911b9bb105d8d86dd6bcf85181dd3cbadd8f
Signed-off-by: Arnaud Joset <arj@odoo.com>
2021-11-17 09:11:55 +00:00
alt-odoo b92ca15aca [FIX] microsoft_calendar: avoid deadlock at token refresh
We should rollback manually first to avoid concurrent access errors/deadlocks when
trying to refresh microsoft calendar token.

opw-2630601

closes odoo/odoo#77955

X-original-commit: 5cd27e3440efae06bee6a96aee39f4d2c509ede7
Signed-off-by: Arnaud Joset <arj-odoo@users.noreply.github.com>
Signed-off-by: Alex Tuyls <alt-odoo@users.noreply.github.com>
2021-10-06 13:50:56 +00:00
Arnaud Joset 7dbc9ec17a [FIX] microsoft_calendar: rename sync range ICP parameter
Before this commit, the ICP used to get the date range of events to sync was improperly named.

closes odoo/odoo#76083

Signed-off-by: LTU-Odoo <IT-Ideas@users.noreply.github.com>
2021-09-07 15:50:21 +00:00
Raphael ColletandXavier Dollé 1595c0ee27 [REF] core: replace thread-local "envs" by cursor-bound "transaction"
Refactor the Environments object into a Transaction object, which is
bound to one cursor, and is no longer shared among several cursors.

The following methods/properties have been changed:
 - Environment.envs no longer works (because of the design change);
 - Environment.manage() is deprecated (no longer useful);
 - Environment.reset() is now an instance method;
 - env.clear_upon_failure() is deprecated in favor of cr.savepoint().

closes odoo/odoo#75598

Related: odoo/enterprise#20451
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Co-authored-by: Xavier Dollé <xdo@odoo.com>
2021-09-03 15:45:46 +00:00
Arnaud Joset b19dc63468 [IMP] calendar,google_calendar,microsoft_calendar: allow to create events with non-default attendee state
Before this commit, it was not possible to create events with defined attendee state. The default value was always set.
This was a limitation when the events were part of a recurrence and all events attendee needed to be created with a known state.

To reproduce, one would create a recurrent event, sync it with Google and in Google, 'decline' this event and the following.
The attendee state was not properly set.

closes odoo/odoo#68700

Taskid: 2484335
Related: odoo/upgrade#2537
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2021-08-26 10:21:02 +00:00
Arnaud Joset f7d16b4599 [IMP] microsoft_calendar: apply the google_calendar improvements into this module
Several imrovements have been made in google_calendar that affets the efficiency of the sync and the validity of the synched data
This commit apply the more relevant modifications to this module.

Taskid: 2484335
Part-of: odoo/odoo#68700
2021-08-26 10:21:02 +00:00
Arnaud Joset 40fd44f618 [IMP] calendar,google_calendar,microsoft_calendar: Improve UI
Before this commit, the calendar UX was not good enough. The look and feel was not modern.
This commit improves a lot of small details, remove unneeded or not mature features (like the videocall location url).

Counted recurrence now brings a better experience. When weekly or montly recurrences are created, occurences in the past are dismissed but before this commit their number was not adapted.
User would end up with less occurences than the provided number without explanations.

Taskid: 2484335
Part-of: odoo/odoo#68700
2021-08-26 10:21:02 +00:00
Adrien Widart 28818c46ed [FIX] microsoft_calendar: archive cancelled recurrence occurrence
Suppose a recurrent event synced with both calendars. Suppose that the
current user is not the organizer. If one occurrence of the event is
cancelled, the user won't be able to sync the calendars.

To reproduce the event:
(Need two Microsoft accounts A01 and A02)
1. [On Microsoft, with A01] Create an event:
    - Recurrent (next 3 days for instance)
    - With A02
2. Set the address mail of current partner with A02's address
3. Sync with Microsoft
    - Note that the 3 occurrences are displayed
4. [On Microsoft, with A01] Cancel one occurrence
5. Sync calendars

Error: A Validation Error is raised: "The operation cannot be completed:
- Create/update: a mandatory field is not set [...]"

At some point, the module updates each occurrence of the event and
stores the occurrence's values:
https://github.com/odoo/odoo/blob/4ae90dd6f9e28e6fdff45c7612a3a756665e1489/addons/microsoft_calendar/models/microsoft_sync.py#L213-L220
However, the cancelled occurrence will be incorrectly stored. Because it
is cancelled, `_microsoft_to_odoo_values` will return {'active': False}:
https://github.com/odoo/odoo/blob/4ae90dd6f9e28e6fdff45c7612a3a756665e1489/addons/microsoft_calendar/models/calendar.py#L63-L65
Therefore, in the previous code, `values` will contain `(<Recurrence
ID>, None, None)`

Later, when applying the recurrence, the module detects all
already-existing occurrences and the others (i.e., those that need to be
created):
https://github.com/odoo/odoo/blob/02886f65e9026e1f7617c8b23c3d87edd358b168/addons/calendar/models/calendar_recurrence.py#L190-L192
where the ranges are tuples like `(<start of the occurrence>, <end>)`.
As a result, `ranges_to_create` will contain such a tuple `(None, None)`
which makes no sense

OPW-2571398

closes odoo/odoo#74052

X-original-commit: ccad42575ae32d7e8ffe72226cbfed2284e0326e
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Signed-off-by: Adrien Widart <adwid@users.noreply.github.com>
2021-07-20 15:49:01 +00:00
Arnaud Joset 8bd566e05a [FIX] microsoft_calendar: send attendee answer to microsoft
Before this commit, the events were not synced when the attendee state was modified.

closes odoo/odoo#73297

X-original-commit: faeaee43adb77fd0d4c36b68a548ac3ab35fdadc
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Signed-off-by: Arnaud Joset <arj-odoo@users.noreply.github.com>
2021-07-06 16:07:00 +00:00
Arnaud Joset 722ea57aa0 [FIX] microsoft_calendar: find attendee based on mail and favour the one with internal users
Before this commit, attendee were found based on the email sent by Microsoft.
When multiple partners would match the mail, the first one was selected but we should favour the partner with a user.
The method _mail_find_partner_from_emails has this exact purpose and therefore is used.

X-original-commit: 4f944f89a5785a2569842dc402c484f21b7aa121
2021-07-06 16:07:00 +00:00
dht-odoo dbf1ab157d [IMP] calendar: improves field type from text to html
Replace text fields to html fields as we have our own 'OdooEditor'.
Indeed, it gives more options to users in the way they format their
content without weighting too much on the UI
(tools appear on demand and not by default).

Adding a new method convert_online_event_desc_to_text
Because online events have fixed format for the description,
this method removes some specific html tags, and converts it into
readable plaintext (to be used in external calendars).

Models -> Fields

1) calendar.event -> description

Task Id: 2499504

X-original-commit: 0d5ca6a6fe8821b4ec19dd603bde116518721792
2021-06-07 05:24:08 +00:00
Raphael Collet 35a9f6c27a [FIX] core: SELF_READABLE_FIELDS and SELF_WRITEABLE_FIELDS on res.users
Avoid setting up those lists with method __init__() on the model, since
the model's class no longer has the expected parent classes.
2021-05-06 07:30:24 +00:00
Jérémy Hennecart ac13964244 [IMP] calendar: improve the way calendar event are displayed
With this commit we try to improve the way the events are displayed
to the user. Now, an event is displayed for each attendee of the event
that are selected in the filter. These events are displayed correctly
based on the status of the attendee in the event.
The colors displayed for the events now represent the attendees and not the
organizer.

If an attendee edit an event, it is edited for all others attendees.
Also, when an attendee that is not the organizer try to delete the event,
then the event is now declined in place of being deleted. If the organizer
delete the event, it is deleted for all attendees.

In case of an event where all attendees have declined it but the organizer,
the organizer see now a danger icon before the name of the event and it's
outlined and not filled with color, no matter of the actual status of the
organizer in the event.

task-2196775
COM PR: odoo/odoo#55190
ENT PR: odoo/enterprise#12196
UPG PR: odoo/upgrade#1532
2021-04-15 16:07:12 +00:00
Jérémy Hennecart f87a0eb763 [REF] calendar: prepare alarm communication configuration
Purpose of this commit is to ease sending mail to attendees using template
by using a template record instead of an xml id. Indeed this allow having
flows using a configurable template instead of an hardcoded one.

Code in calendar_sms is split into main models to ease future improvements
related to SMS.

Taks ID-2191254
COM PR odoo/odoo#68443
2021-03-30 12:14:59 +00:00
Adrien Widart 642f72bfcc [FIX] microsoft_calendar: warn user if attendee without email
When syncing both Odoo and Outlook Calendar, if one Odoo event has an
attendee who does not have any email adress, it will lead to a traceback
error.

To reproduce the error:
1. Create a partner P who does not have an email address
2. In Calendar, create an event E with P
3. Sync with Outlook

Error: An Odoo Error is raised. When syncing from Outlook to Odoo, it
also sync the E-event (in case the latter has been updated on Outlook).
The Microsoft2Odoo syncing uses the email address of each attendee.
Since P does not have any, this creates the error.

Although Odoo allows the use of participants without email, this is not
the case for Outlook. On Outlook Calendar, as soon as a user adds an
attendee to an Event, Outlook will want to send an invitation before
saving this event (so, if the participant does not have any email
address, it won't be possible to save the event).

When syncing, the E-event will be added to Outlook Calendar. However,
for the same reasons as in the previous paragraph, it will not be
possible to update this event from Outlook Calendar.

Therefore, the solution is to prevent the user from having attendees
without email when his calendar is synchronized with Outlook.

OPW-2439027

closes odoo/odoo#68407

X-original-commit: dbb65f3abfbc7d6e3d8167839659eac79b1e6b31
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Signed-off-by: Adrien Widart <adwid@users.noreply.github.com>
2021-03-26 14:13:15 +00:00
YOGRAJ TANDELandMohammed Shekha 7fb9c81296 [IMP] calendar,lunch: change field names
with this commit we changes field names for week days like su, mo, tu etc. to
sun, mon, tue and so on in calendar module, this is going to be used in
task 2317795 where we developed recurrency module for recurrency mixin.

Also with this commit we change field names of weekdays in lunch module to have
same name as we have in calendar and project module so that we can easily use
custom widget "web_weekly_recurrence" instead of defining boolean field in xml
for each day.

task-2335399

Co-authored-by: Mohammed Shekha <msh@odoo.com>
2021-03-26 12:25:44 +00:00
Thibault Francois 30f4be4889 [FIX] (google|microsoft)_calendar: make sync more resilient
Issue
-----
- Currently the cron can take too much time and timeout.
  In case of timeout process data are rollback.
  The sync per user also crash and stop the process for all user and make
  the transaction rollback

  In both case we cannot ensure that all user will end up synchronized

- The real time sync can end up in deadlock:
  If you create a holiday, it trigger a write on the user and the
  creation of an event that will be synchronize with google

  The synchronization may ask for a new token if this request fail
  a new cursor is create to empty on the user the refresh token.
  2 cursor that are trying to write on the same record => Deadlock

- Bad refresh token management
  When the refresh token is not anymore valid it's erased but
  the calendar_token and validity are kept. Is odoo consider
  the token valid it will try to sync an event with google|microsoft
  despite the refresh token is not valid anymore. Of course this lead to
  an error and the impossibility to create an event anymore without
  manually wiping the calendar_token and calendar_token_validity

- Error 401 are handled in context manager
(google|microsoft)_calendar_token, but get_*_calendar_token never raise
http error only user error.

Solution
---------

- Improve cron resilience
	- Commit between each user and rollback in case of issue for a user
	- Solve the issue when stop < start
        - Solve issue with rrule not being the first element in the list
          of recurrence
	- Improve perf when searching for organizer
	- In order to limit the volume during the first synchronization, we only
	synchronized event from x days in the past to x days in the future with
	x = 365 by default
	- Limit the number of event to synchronize to google each time to 200,
	since this operation is time consuming (1 request is sent per event)

- Avoid deadlock
  A new cursor is not needed, we only need to ensure that write on the
  user is done with a clean cursor and will be commited despite the error
  raise. So rollabck before the write and commit explicitly afterwards

- Erase properly all the token and the token validity if the refresh token is not valid anymore
	- For google calendar, erase also the token in case of 401
          error: Wrong client id, this mean the database parameter have been
          change and all the user should reconfigure the synchronization

- Directly handle error 401 with error 400 in refresh_token method

closes odoo/odoo#66250

X-original-commit: 486f69abad6226e5ce016ad89a0eeb103d709a3f
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2021-03-25 09:55:10 +00:00
Krupal OzaandThibault Delavallee bc9bc2686c [IMP] calendar: improve main data templates
Purpose of this commit is to make templates easier to preview and edit as
weel as to improve their content.

This is achieved notably by lessening use of custom rendering context and
trying to fix as much error-prone jinja statements.

In this commit we also make ``calendar_template_meeting_reminder`` template
looking more like other templates. There were some rendering differences that
do not seem really wanted.

``calendar_template_meeting_reminder`` was also using an old ``force_event_id``
key not replaced by recurrent_id field on attendee.

This commit improves few strings of the invitation mail being sent while
booking an online appointment. Online appointment is computed based on
``appointment_type_id`` field being defined. Some tweaks in wording made it
necessary to know if recipient is the responsible, customer or an added
attendee on the event, leading to some tooling code added on event model.

The main changes includes

 * for customer, remove the CTAs to accept / decline event as attendee are
   automatically set as accepted;
 * depending on recipient, improve wording of the mail accordingly and mention
   appointment type in the mail;

Task ID-2199620
COM PR odoo/odoo#64925
ENT PR odoo/enterprise#15914
UPG PR odoo/upgrade#2282

Co-Authored-By: Krupal Oza <koz@odoo.com>
Co-Authored-By: Thibault Delavallee <tde@odoo.com>
2021-03-24 15:16:42 +00:00
Adrien Widart 69fddf832f [FIX] microsoft_calendar: add current partner to attendees
When synced, if the user has an event on Microsoft Calendar and if this
user is not the organizer (he is only an attendee), he will have to
enable "Everybody's calendars" on Odoo Calendar to see this event.

To reproduce the error:
(Need one Google/Microsoft account A01 and one Microsoft account A02)
1. With A01, on Google/Microsoft calendar, create an event and invite A02
2. On Odoo, enable the sync with Microsoft
	- See [instructions](https://www.odoo.com/documentation/user/14.0/general/calendars/outlook/outlook_calendar.html)
3. Go to Odoo Calendar, click on "Sync With Outlook"
	- ! The sync must be done with A02

Error: The event is not displayed. The user must enable "Everybody's
calendars" to see it.

The problem comes from the attendees creation: it uses Microsoft
attendees' email address to link a partner with the event. However,
nothing ensures or requires that A02's email address is the same than
current partner's one. As a result, it is possible that the current
partner is not among the attendees. Moreover, Microsoft does not say
which attendee is the synced one. Thus, this fix always adds the current
partner to the attendees, so he will no longer need to enable
"Everybody's calendars".

OPW-2439189

closes odoo/odoo#66103

X-original-commit: 7579787c101923d450217cd167f50b9fcf21c690
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Signed-off-by: Adrien Widart <adwid@users.noreply.github.com>
2021-02-12 16:32:09 +00:00
Aurélien (avd) 8488086f94 [FIX] google/microsoft_calendar: Use the standard field whitelist on res.users
Purpose
=======

Better use standard mechanism right ?

closes odoo/odoo#64869

Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2021-01-22 09:55:53 +00:00
Kevin Baptiste 0c4ee216d7 [IMP] microsoft_account: allow configuration of endpoints
The endpoints were hardcoded in the application code. This commit aims
at making them overridable with system parameters:

 - `microsoft_account.auth_endpoint` defaults to
    https://login.microsoftonline.com/common/oauth2/v2.0/authorize

 - `microsoft_account.token_endpoint` defaults to
    https://login.microsoftonline.com/common/oauth2/v2.0/token

This change allows customers to restrict the tenant the API targets[0].

[0] https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-v2-protocols#endpoints

closes odoo/odoo#62945

Taskid: 2413197
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-12-07 10:19:27 +00:00
Andrea Grazioso (agr-odoo) e7c92594f0 [FIX] microsoft_calendar: fix recurrence event creation
Create an event as follows:

- Recurrent
- Repeat every 1 Months
- Until End date <far in future>
- Day of Month Day of Month First Monday

An exception will raise

opw-2412598

closes odoo/odoo#63601

X-original-commit: 4cb599f694eecd2a3c96ed25a055f0b9030a5864
Signed-off-by: agr-odoo <agr-odoo@users.noreply.github.com>
2020-12-18 17:40:10 +00:00
Aurélien (avd) 005741e509 [IMP] microsoft_calendar: add stop synchronization button
Add the possibility to stop/restart the synchronization with
Outlook calendar.

Change the calendar event popover in the calendar view to
display an Archive button if event synced at least once.

Add some tests for the new stop/restart feature.

(PS: this is essentially the same commit as the one for the
google_calendar module except for the JS popover and python
tests).
2020-12-10 10:23:10 +01:00
Adrien Widart 78eecf1a81 [FIX] microsoft_calendar: disable Odoo emails
When synced with Outlook, if a user adds an event to the Odoo Calendar,
both Outlook and Odoo will send an invitation to attendees.

To reproduce the error:
(Need calendar)
1. Set up a mail catcher
2. Clean the calendar
3. Sync with Outlook
	- [Steps](https://www.odoo.com/documentation/user/14.0/general/calendars/outlook/outlook_calendar.html)
4. In Calendar, create a new event
	- Add some attendees
5. Save

=> The attendees will receive two invitations: one from Odoo and a
second from Outlook.

When synced, Odoo should not manage the emails sending.

OPW-2387296

closes odoo/odoo#63028

X-original-commit: 694452e5581aa28ae89024a6b5f70a273fb2bdf8
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-12-08 14:03:29 +00:00
Adrian Torres 679185f3e8 [IMP] *: replace all raises inside unlink by api.ondelete
With this commit, all instances of errors being raised inside
`BaseModel.unlink` overrides are moved into methods decorated with
`api.ondelete` which is safer.
2020-12-04 09:16:16 +00:00
jbm-odoo edee29613d [FIX] microsoft_calendar: Badge when sync is active
Add a cron to sync events in Microsoft calendar
In Google and Microsoft calendar: remove 'sync with ...' button
when the synchronization is already activated, and replace it by a
badge.

closes odoo/odoo#58197

Taskid: 2329313
X-original-commit: 255eb91dd5e9fb39a7625064d1ba8e0b492bfb85
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Signed-off-by: jbm-odoo <jbm-odoo@users.noreply.github.com>
2020-09-22 10:08:27 +00:00
Raphael Collet 317765c8f3 [IMP] core: deprecate method cr.after()
Use the more convenient `cr.postcommit.add()` instead.

closes odoo/odoo#57043

X-original-commit: e9e37091a65d5ae2caa9eb6728abaffb7c9555a8
Related: odoo/enterprise#12928
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-09-03 14:29:39 +00:00
jbm-odoo 9dc3057e8e [ADD] calendar_microsoft: Synchronize Microsoft calendar with Odoo
TaskID 2223219

closes odoo/odoo#54936

Related: odoo/upgrade#1557
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-08-05 13:47:42 +00:00