Xavier ALT (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-client-web/6.0-opw-50873-xal into 
lp:openobject-client-web.

Requested reviews:
  OpenERP Core Team (openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-client-web/6.0-opw-50873-xal/+merge/115508

Hi,

This fix Popup window stacking. Currently, all popups are stacked on the root 
window. If we open a many2one field, then open sub-records (many2many, 
one2many), those child popup should be stacked on the "many2one" popup window, 
otherwise we're getting wrong context and view simply crash.

Regards,
Xavier
-- 
https://code.launchpad.net/~openerp-dev/openobject-client-web/6.0-opw-50873-xal/+merge/115508
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-client-web/6.0-opw-50873-xal.
=== modified file 'addons/openerp/controllers/openo2m.py'
--- addons/openerp/controllers/openo2m.py	2011-11-17 05:56:40 +0000
+++ addons/openerp/controllers/openo2m.py	2012-07-18 10:09:24 +0000
@@ -49,7 +49,13 @@
         form = tw.form_view.ViewForm(vp, name="view_form", action="/openerp/openo2m/save")
         cherrypy.request.terp_validators = {}
 
-        wid = form.screen.widget.get_widgets_by_name(params.o2m)[0]
+        widname = params.o2m
+        try:
+            wid = form.screen.widget.get_widgets_by_name(widname)[0]
+        except IndexError:
+            if '/' in widname:
+                widname = widname.split('/')[-1]
+            wid = form.screen.widget.get_widgets_by_name(widname)[0]
 
         # save view_params for later phazes
         vp = vp.make_plain('_terp_view_params/')

=== modified file 'addons/openerp/static/javascript/m2o.js'
--- addons/openerp/static/javascript/m2o.js	2012-06-19 07:42:01 +0000
+++ addons/openerp/static/javascript/m2o.js	2012-07-18 10:09:24 +0000
@@ -666,8 +666,8 @@
         var $this;
         if(this == $) $this = $(window);
         else $this = $(this);
-        if(window != window.top) {
-            return window.top.jQuery.m2o.apply($this[0], arguments);
+        if(window != window.parent) {
+            return window.parent.jQuery.m2o.apply($this[0], arguments);
         }
         // We're at the top-level window, $this is the window from which the
         // original $.m2o call was performed, window being the current window

=== modified file 'addons/openerp/static/javascript/o2m.js'
--- addons/openerp/static/javascript/o2m.js	2012-06-18 12:32:01 +0000
+++ addons/openerp/static/javascript/o2m.js	2012-07-18 10:09:24 +0000
@@ -190,6 +190,7 @@
             _terp_parent_view_id: this.parent_view_id,
             _terp_o2m: o2m_name ? o2m_name : this.name,
             _terp_o2m_model: this.model,
+            _terp_o2m_fullname: this.name,
             _terp_parent_view_type: this.parent_view_type,
             _terp_editable: readonly ? 0 : 1,
             _terp_m2o: this.m2o
@@ -276,7 +277,7 @@
             id: frame_identifier,
             name: frame_identifier
         }, {'source-window': $this[0],
-            'list': options['_terp_o2m']
+            'list': options['_terp_o2m_fullname']
         }, {
             width: '70%',
             height: '90%',
@@ -391,8 +392,14 @@
         var $this;
         if(this == $) $this = $(window);
         else $this = $(this);
-        if(window != window.top) {
-            return window.top.jQuery.o2m.apply($this[0], arguments);
+        var form_controller = window.form_controller;
+        var is_root_window = false;
+        if (form_controller == '/openerp/openm2o' || form_controller == '/openerp/search/new') {
+            // stop unstacking window on M2O popup window
+            is_root_window = true;
+        }
+        if(window != window.parent && !is_root_window) {
+            return window.parent.jQuery.o2m.apply($this[0], arguments);
         }
         // We're at the top-level window, $this is the window from which the
         // original $.o2m call was performed, window being the current window

=== modified file 'openobject/static/javascript/openobject/openobject.dom.js'
--- openobject/static/javascript/openobject/openobject.dom.js	2011-04-08 09:24:41 +0000
+++ openobject/static/javascript/openobject/openobject.dom.js	2012-07-18 10:09:24 +0000
@@ -144,8 +144,14 @@
         var $this;
         if(this == $) $this = $(window);
         else $this = $(this);
-        if(window != window.top) {
-            return window.top.jQuery.frame_dialog.apply($this[0], arguments);
+        var form_controller = window.form_controller;
+        var is_root_window = false;
+        if (form_controller == '/openerp/openm2o' || form_controller == '/openerp/search/new') {
+            // stop unstacking window on M2O popup window, Search window 'New'
+            is_root_window = true;
+        }
+        if(window != window.parent && !is_root_window) {
+            return window.parent.jQuery.frame_dialog.apply($this[0], arguments);
         }
         return open($this, frame_attrs, data, options);
     }

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to