diff --git a/addons/google_calendar/i18n/google_calendar.pot b/addons/google_calendar/i18n/google_calendar.pot index e76e934fbf7..629573f0c7c 100644 --- a/addons/google_calendar/i18n/google_calendar.pot +++ b/addons/google_calendar/i18n/google_calendar.pot @@ -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 diff --git a/addons/google_calendar/models/google_sync.py b/addons/google_calendar/models/google_sync.py index 06c09bc48b5..0007e5d10c8 100644 --- a/addons/google_calendar/models/google_sync.py +++ b/addons/google_calendar/models/google_sync.py @@ -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