diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/calendar/static/src/js/mail_activity.js | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/calendar/static/src/js/mail_activity.js')
| -rw-r--r-- | addons/calendar/static/src/js/mail_activity.js | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/addons/calendar/static/src/js/mail_activity.js b/addons/calendar/static/src/js/mail_activity.js new file mode 100644 index 00000000..3c478921 --- /dev/null +++ b/addons/calendar/static/src/js/mail_activity.js @@ -0,0 +1,60 @@ +odoo.define('calendar.Activity', function (require) { +"use strict"; + +var Activity = require('mail.Activity'); +var Dialog = require('web.Dialog'); +var core = require('web.core'); +var _t = core._t; + +Activity.include({ + + /** + * Override behavior to redirect to calendar event instead of activity + * + * @override + */ + _onEditActivity: function (event, options) { + var self = this; + var activity_id = $(event.currentTarget).data('activity-id'); + var activity = _.find(this.activities, function (act) { return act.id === activity_id; }); + if (activity && activity.activity_category === 'meeting' && activity.calendar_event_id) { + return self._super(event, _.extend({ + res_model: 'calendar.event', + res_id: activity.calendar_event_id[0], + })); + } + return self._super(event, options); + }, + + /** + * Override behavior to warn that the calendar event is about to be removed as well + * + * @override + */ + _onUnlinkActivity: function (event, options) { + event.preventDefault(); + var self = this; + var activity_id = $(event.currentTarget).data('activity-id'); + var activity = _.find(this.activities, function (act) { return act.id === activity_id; }); + if (activity && activity.activity_category === 'meeting' && activity.calendar_event_id) { + Dialog.confirm( + self, + _t("The activity is linked to a meeting. Deleting it will remove the meeting as well. Do you want to proceed ?"), { + confirm_callback: function () { + return self._rpc({ + model: 'mail.activity', + method: 'unlink_w_meeting', + args: [[activity_id]], + }) + .then(self._reload.bind(self, {activity: true})); + }, + } + ); + } + else { + return self._super(event, options); + } + }, +}); + +}); |
