[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#64957 X-original-commit: 109ffab4a5d3e77d330d7fa4cc5fd39017bdf561 Signed-off-by: Adrien Widart <adwid@users.noreply.github.com>
This commit is contained in:
@@ -4,10 +4,10 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 14.0\n"
|
||||
"Project-Id-Version: Odoo Server 14.0+e\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-11-27 11:24+0000\n"
|
||||
"PO-Revision-Date: 2020-11-27 11:24+0000\n"
|
||||
"PO-Revision-Date: 2021-01-22 08:05+0000\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
@@ -364,14 +364,6 @@ msgstr ""
|
||||
msgid "Users"
|
||||
msgstr ""
|
||||
|
||||
#. module: google_calendar
|
||||
#: code:addons/google_calendar/models/google_sync.py:0
|
||||
#, python-format
|
||||
msgid ""
|
||||
"You cannot delete a record synchronized with Google Calendar, archive it "
|
||||
"instead."
|
||||
msgstr ""
|
||||
|
||||
#. module: google_calendar
|
||||
#. openerp-web
|
||||
#: code:addons/google_calendar/static/src/js/google_calendar.js:0
|
||||
|
||||
@@ -97,13 +97,6 @@ class GoogleSync(models.AbstractModel):
|
||||
record._google_insert(google_service, record._google_values(), timeout=3)
|
||||
return records
|
||||
|
||||
@api.ondelete(at_uninstall=False)
|
||||
def _unlink_except_synchronized(self):
|
||||
if self.env.context.get('archive_on_error') and self._active_name:
|
||||
return
|
||||
if self.filtered('google_id'):
|
||||
raise UserError(_("You cannot delete a record synchronized with Google Calendar, archive it instead."))
|
||||
|
||||
def unlink(self):
|
||||
"""We can't delete an event that is also in Google Calendar. Otherwise we would
|
||||
have no clue that the event must must deleted from Google Calendar at the next sync.
|
||||
@@ -113,6 +106,12 @@ class GoogleSync(models.AbstractModel):
|
||||
if self.env.context.get('archive_on_error') and self._active_name:
|
||||
synced.write({self._active_name: False})
|
||||
self = self - synced
|
||||
elif synced:
|
||||
# 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
|
||||
|
||||
Reference in New Issue
Block a user