Fabien Meghazi (OpenERP) has proposed merging 
lp:~openerp-dev/openerp-web/7.0-fix-calendar-formpopup-view into 
lp:openerp-web/7.0.

Requested reviews:
  Xavier (Open ERP) (xmo)

For more details, see:
https://code.launchpad.net/~openerp-dev/openerp-web/7.0-fix-calendar-formpopup-view/+merge/146401

When creating or editing an item by clicking it's title or an empty cell from 
the calendar view, the form view opened in a popup is the default one on the 
model. It should be the same view as the one mentioned in the action if any. 
Also, the title used in the dialog should also match the action's title if any.

This branch adds instance.web.ViewManager#get_view_id(view_type)
It also fetch the title of the popup from the parent if it's a 
ViewManagerAction,
    otherwise, use the current's view title.
-- 
https://code.launchpad.net/~openerp-dev/openerp-web/7.0-fix-calendar-formpopup-view/+merge/146401
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openerp-web/7.0-fix-calendar-formpopup-view.
=== modified file 'addons/web/static/src/js/view_form.js'
--- addons/web/static/src/js/view_form.js	2013-01-24 14:40:18 +0000
+++ addons/web/static/src/js/view_form.js	2013-02-04 13:18:33 +0000
@@ -4450,6 +4450,7 @@
      *  options:
      *  -readonly: only applicable when not in creation mode, default to false
      * - alternative_form_view
+     * - view_id
      * - write_function
      * - read_function
      * - create_function
@@ -4516,7 +4517,7 @@
         _.extend(options, {
             $buttons: this.$buttonpane,
         });
-        this.view_form = new instance.web.FormView(this, this.dataset, false, options);
+        this.view_form = new instance.web.FormView(this, this.dataset, this.options.view_id || false, options);
         if (this.options.alternative_form_view) {
             this.view_form.set_embedded_view(this.options.alternative_form_view);
         }

=== modified file 'addons/web/static/src/js/views.js'
--- addons/web/static/src/js/views.js	2013-01-14 09:30:14 +0000
+++ addons/web/static/src/js/views.js	2013-02-04 13:18:33 +0000
@@ -597,6 +597,12 @@
             self.trigger("controller_inited",view_type,controller);
         });
     },
+    /**
+     * @returns {Number|Boolean} the view id of the given type, false if not found
+     */
+    get_view_id: function(view_type) {
+        return this.views[view_type] && this.views[view_type].view_id || false;
+    },
     set_title: function(title) {
         this.$el.find('.oe_view_title_text:first').text(title);
     },

=== modified file 'addons/web_calendar/static/src/js/calendar.js'
--- addons/web_calendar/static/src/js/calendar.js	2012-12-18 15:16:57 +0000
+++ addons/web_calendar/static/src/js/calendar.js	2013-02-04 13:18:33 +0000
@@ -416,6 +416,15 @@
     },
     slow_create: function(event_id, event_obj) {
         var self = this;
+        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 (this.current_mode() === 'month') {
             event_obj['start_date'].addHours(8);
             if (event_obj._length === 1) {
@@ -432,8 +441,9 @@
         var something_saved = false;
         var pop = new instance.web.form.FormOpenPopup(this);
         pop.show_element(this.dataset.model, null, this.dataset.get_context(defaults), {
-            title: _t("Create: ") + ' ' + this.name,
+            title: _t("Create: ") + ' ' + title,
             disable_multiple_selection: true,
+            view_id: view_id,
         });
         pop.on('closed', self, function() {
             if (!something_saved) {
@@ -450,6 +460,15 @@
     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 !!??
@@ -467,7 +486,8 @@
             var pop = new instance.web.form.FormOpenPopup(this);
             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: ") + this.name
+                title: _t("Edit: ") + title,
+                view_id: view_id,
             });
             pop.on('write_completed', self, function(){
                 self.reload_event(id_from_dataset);

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : openerp-dev-gtk@lists.launchpad.net
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to