← Back to team overview

openerp-dev-web team mailing list archive

[Merge] lp:~openerp-dev/openobject-client-web/pop-up-reopen into lp:openobject-client-web

 

vda(Open ERP) has proposed merging lp:~openerp-dev/openobject-client-web/pop-up-reopen into lp:openobject-client-web.

Requested reviews:
  OpenERP SA's Web Client R&D (openerp-dev-web)
Related bugs:
  #684798 in a pop-up, if the background view is empty, the cancel button reopens the pop-up
  https://bugs.launchpad.net/bugs/684798


in a pop-up, if the background view is empty, the cancel button reopens the pop-up
-- 
https://code.launchpad.net/~openerp-dev/openobject-client-web/pop-up-reopen/+merge/42907
Your team OpenERP SA's Web Client R&D is requested to review the proposed merge of lp:~openerp-dev/openobject-client-web/pop-up-reopen into lp:openobject-client-web.
=== modified file 'addons/openerp/controllers/actions.py'
--- addons/openerp/controllers/actions.py	2010-11-23 11:50:14 +0000
+++ addons/openerp/controllers/actions.py	2010-12-07 05:08:57 +0000
@@ -326,12 +326,16 @@
         'action': simplejson.dumps(dict(action, opened=True)),
         'data': simplejson.dumps(data)
     }))
+    window_opener = 0
+    if action['target'] == 'new' and not action['view_id']:
+        window_opener = 1
     cherrypy.response.headers['X-Target'] = action['target']
     cherrypy.response.headers['Location'] = url
+    cherrypy.response.headers['window_opener'] = window_opener
     return """<script type="text/javascript">
-        window.top.openAction('%s', '%s');
+        window.top.openAction('%s', '%s', '%s');
     </script>
-    """ % (url, action['target'])
+    """ % (url, action['target'], window_opener)
 
 def execute(action, **data):
     """Execute the action with the provided data. for internal use only.
@@ -445,6 +449,7 @@
         key = keyact.keys()[0]
         if data.get('context'):
             data['context'].update(rpc.session.context)
+        
         return execute(keyact[key], **data)
     else:
         return Selection().create(keyact, **data)

=== modified file 'addons/openerp/controllers/templates/closepopup.mako'
--- addons/openerp/controllers/templates/closepopup.mako	2010-11-17 15:05:53 +0000
+++ addons/openerp/controllers/templates/closepopup.mako	2010-12-07 05:08:57 +0000
@@ -21,7 +21,9 @@
             switch($doc.find('#_terp_view_type').val()) {
                 case null:
                 case undefined:
-                    topWindow.location.reload();
+                    if(!($doc.find('#window_opener') && $doc.find('#window_opener').val())) {
+                        topWindow.location.reload();
+                    }
                     return;
                 case 'tree':
                     new topWindow.ListView('_terp_list').reload();

=== modified file 'addons/openerp/static/javascript/openerp/openerp.base.js'
--- addons/openerp/static/javascript/openerp/openerp.base.js	2010-11-29 11:13:59 +0000
+++ addons/openerp/static/javascript/openerp/openerp.base.js	2010-12-07 05:08:57 +0000
@@ -74,6 +74,7 @@
 function doLoadingSuccess(app) {
     return function (data, status, xhr) {
         var target = xhr.getResponseHeader('X-Target');
+        var window_opener = xhr.getResponseHeader('window_opener');
         if(target) {
             var _openAction;
             if (window.top.openAction) {
@@ -81,7 +82,7 @@
             } else {
                 _openAction = openAction;
             }
-            _openAction(xhr.getResponseHeader('Location'), target);
+            _openAction(xhr.getResponseHeader('Location'), target, window_opener);
             return;
         }
         jQuery(window).trigger('before-appcontent-change');
@@ -96,10 +97,18 @@
  * @param action_url the URL of the action to open
  * @param target the target, if any, defaults to 'current'
  */
-function openAction(action_url, target) {
+function openAction(action_url, target, window_opener) {
+    window_opener = parseInt(window_opener) || 0;
     var $dialogs = jQuery('.action-dialog');
     switch(target) {
         case 'new':
+            if(window_opener == 1) {
+                if(jQuery('#appContent').length) {
+                    jQuery('#appContent').append(
+                        jQuery('<input>', {'type': 'hidden', 'id': 'window_opener'}).val(true)
+                    );
+                }
+            }
             var $contentFrame = jQuery('<iframe>', {
                 src: action_url,
                 frameborder: 0,


Follow ups