diff options
| author | Adrien Widart <awt@odoo.com> | 2021-01-21 15:29:36 +0000 |
|---|---|---|
| committer | Adrien Widart <awt@odoo.com> | 2021-01-22 08:08:14 +0000 |
| commit | 47bfdf0592a5dd93870ca1a9da326351d70087bb (patch) | |
| tree | 9fa9e22caf393deac582d47f6f3cfdd778aa6105 /addons/google_calendar/models/google_sync.py | |
| parent | f332541bc84d6110c90d4c5e736892f185fff3df (diff) | |
[FIX] google_calendar: enable the event deletion
When using the Calender synced with Google, if the user tries to delete
an event, an error message is displayed: he has to archive it instead.
To reproduce the error:
1. Sync Odoo Calendar with Gogle Calendar
2. Add an event
3. Click on it > Delete
Error: UserError message: "You cannot delete a record synchronized with
Google Calendar, archive it instead"
To make the flow simpler and faster, when clicking on "Delete", the
server will archive the event. When archiving an event, the server
deletes the corresponding event on Google Calendar. As a result, the
next time the user loads his Odoo Calendar, the sync Google->Odoo will
delete the archived event.
OPW-2440339
closes odoo/odoo#64874
Signed-off-by: Adrien Widart <adwid@users.noreply.github.com>
Diffstat (limited to 'addons/google_calendar/models/google_sync.py')
| -rw-r--r-- | addons/google_calendar/models/google_sync.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/addons/google_calendar/models/google_sync.py b/addons/google_calendar/models/google_sync.py index 7fcb66f50b2..c5c549b752f 100644 --- a/addons/google_calendar/models/google_sync.py +++ b/addons/google_calendar/models/google_sync.py @@ -104,7 +104,11 @@ class GoogleSync(models.AbstractModel): synced.write({self._active_name: False}) self = self - synced elif synced: - raise UserError(_("You cannot delete a record synchronized with Google Calendar, archive it instead.")) + # Since we can not delete such an event (see method comment), we archive it. + # Notice that archiving an event will delete the associated event on Google. + # Then, since it has been deleted on Google, the event is also deleted on Odoo DB (_sync_google2odoo). + self.action_archive() + return True return super().unlink() @api.model |
