diff --git a/addons/web_calendar/static/src/js/calendar.js b/addons/web_calendar/static/src/js/calendar.js index e42ec2ba1c8..3c9a8a6fa9d 100644 --- a/addons/web_calendar/static/src/js/calendar.js +++ b/addons/web_calendar/static/src/js/calendar.js @@ -414,17 +414,22 @@ instance.web_calendar.CalendarView = instance.web.View.extend({ self.slow_create(event_id, event_obj); }); }, - slow_create: function(event_id, event_obj) { - var self = this; - var view_id = false; - var title = this.name; + get_form_popup_infos: function() { var parent = this.getParent(); + var infos = { + view_id: false, + title: this.name, + }; if (parent instanceof instance.web.ViewManager) { - view_id = parent.get_view_id('form'); - if (parent instanceof instance.web.ViewManagerAction) { - title = parent.get_action_manager().get_title(); + infos.view_id = parent.get_view_id('form'); + if (parent instanceof instance.web.ViewManagerAction && parent.action && parent.action.name) { + infos.title = parent.action.name; } } + return infos; + }, + slow_create: function(event_id, event_obj) { + var self = this; if (this.current_mode() === 'month') { event_obj['start_date'].addHours(8); if (event_obj._length === 1) { @@ -440,10 +445,11 @@ instance.web_calendar.CalendarView = instance.web.View.extend({ }); var something_saved = false; var pop = new instance.web.form.FormOpenPopup(this); + var pop_infos = this.get_form_popup_infos(); pop.show_element(this.dataset.model, null, this.dataset.get_context(defaults), { - title: _t("Create: ") + ' ' + title, + title: _.str.sprintf(_t("Create: %s"), pop_infos.title), disable_multiple_selection: true, - view_id: view_id, + view_id: pop_infos.view_id, }); pop.on('closed', self, function() { if (!something_saved) { @@ -460,15 +466,6 @@ instance.web_calendar.CalendarView = instance.web.View.extend({ open_event: function(event_id) { var self = this; var index = this.dataset.get_id_index(event_id); - var view_id = false; - var title = this.name; - var parent = this.getParent(); - if (parent instanceof instance.web.ViewManager) { - view_id = parent.get_view_id('form'); - if (parent instanceof instance.web.ViewManagerAction) { - title = parent.get_action_manager().get_title(); - } - } if (index === null) { // Some weird behaviour in dhtmlx scheduler could lead to this case // eg: making multiple days event in week view, dhtmlx doesn't trigger eventAdded !!?? @@ -484,10 +481,11 @@ instance.web_calendar.CalendarView = instance.web.View.extend({ }); } else { var pop = new instance.web.form.FormOpenPopup(this); + var pop_infos = this.get_form_popup_infos(); var id_from_dataset = this.dataset.ids[index]; // dhtmlx scheduler loses id's type pop.show_element(this.dataset.model, id_from_dataset, this.dataset.get_context(), { - title: _t("Edit: ") + title, - view_id: view_id, + title: _.str.sprintf(_t("Edit: %s"), pop_infos.title), + view_id: pop_infos.view_id, }); pop.on('write_completed', self, function(){ self.reload_event(id_from_dataset);