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

Proposed by Vaibhav Darji
Status: Rejected
Rejected by: Xavier (Open ERP)
Proposed branch: lp:~openerp-dev/openobject-client-web/pop-up-reopen
Merge into: lp:openobject-client-web/trunk
Diff against target: 86 lines (+21/-5)
3 files modified
addons/openerp/controllers/actions.py (+7/-2)
addons/openerp/controllers/templates/closepopup.mako (+3/-1)
addons/openerp/static/javascript/openerp/openerp.base.js (+11/-2)
To merge this branch: bzr merge lp:~openerp-dev/openobject-client-web/pop-up-reopen
Reviewer Review Type Date Requested Status
Xavier (Open ERP) (community) Disapprove
Review via email: mp+42907@code.launchpad.net

Description of the change

in a pop-up, if the background view is empty, the cancel button reopens the pop-up

To post a comment you must log in.
Revision history for this message
Xavier (Open ERP) (xmo-deactivatedaccount) wrote :

Mis-identified issue: the core problem is that the action is opened from the menu via a regular action and set as the current URL in openLink. The long-term fix is that link-setting should probably be done in doLoadingSuccess (and maybe loadingError, so the user can just Ctrl-R or Ctrl-F5 to reload a failed page?) rather than openLink (so we avoid setting the current URL to an action of target=new for instance).

This is just a work-around, it doesn't fix the actual problem (if you open the wizard, close it and then Ctrl-R or F5, it will reopen, and so it will break user history as well).

I also am not sure about the need to reload the backing view in case of a cancel. If it's a special=cancel button there is no server action being performed so I would think there's no need to reload the backing view.

review: Disapprove

Unmerged revisions

4035. By Vaibhav Darji

[FIX] Issue of popup reopen when background view is empty.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'addons/openerp/controllers/actions.py'
2--- addons/openerp/controllers/actions.py 2010-11-23 11:50:14 +0000
3+++ addons/openerp/controllers/actions.py 2010-12-07 05:08:57 +0000
4@@ -326,12 +326,16 @@
5 'action': simplejson.dumps(dict(action, opened=True)),
6 'data': simplejson.dumps(data)
7 }))
8+ window_opener = 0
9+ if action['target'] == 'new' and not action['view_id']:
10+ window_opener = 1
11 cherrypy.response.headers['X-Target'] = action['target']
12 cherrypy.response.headers['Location'] = url
13+ cherrypy.response.headers['window_opener'] = window_opener
14 return """<script type="text/javascript">
15- window.top.openAction('%s', '%s');
16+ window.top.openAction('%s', '%s', '%s');
17 </script>
18- """ % (url, action['target'])
19+ """ % (url, action['target'], window_opener)
20
21 def execute(action, **data):
22 """Execute the action with the provided data. for internal use only.
23@@ -445,6 +449,7 @@
24 key = keyact.keys()[0]
25 if data.get('context'):
26 data['context'].update(rpc.session.context)
27+
28 return execute(keyact[key], **data)
29 else:
30 return Selection().create(keyact, **data)
31
32=== modified file 'addons/openerp/controllers/templates/closepopup.mako'
33--- addons/openerp/controllers/templates/closepopup.mako 2010-11-17 15:05:53 +0000
34+++ addons/openerp/controllers/templates/closepopup.mako 2010-12-07 05:08:57 +0000
35@@ -21,7 +21,9 @@
36 switch($doc.find('#_terp_view_type').val()) {
37 case null:
38 case undefined:
39- topWindow.location.reload();
40+ if(!($doc.find('#window_opener') && $doc.find('#window_opener').val())) {
41+ topWindow.location.reload();
42+ }
43 return;
44 case 'tree':
45 new topWindow.ListView('_terp_list').reload();
46
47=== modified file 'addons/openerp/static/javascript/openerp/openerp.base.js'
48--- addons/openerp/static/javascript/openerp/openerp.base.js 2010-11-29 11:13:59 +0000
49+++ addons/openerp/static/javascript/openerp/openerp.base.js 2010-12-07 05:08:57 +0000
50@@ -74,6 +74,7 @@
51 function doLoadingSuccess(app) {
52 return function (data, status, xhr) {
53 var target = xhr.getResponseHeader('X-Target');
54+ var window_opener = xhr.getResponseHeader('window_opener');
55 if(target) {
56 var _openAction;
57 if (window.top.openAction) {
58@@ -81,7 +82,7 @@
59 } else {
60 _openAction = openAction;
61 }
62- _openAction(xhr.getResponseHeader('Location'), target);
63+ _openAction(xhr.getResponseHeader('Location'), target, window_opener);
64 return;
65 }
66 jQuery(window).trigger('before-appcontent-change');
67@@ -96,10 +97,18 @@
68 * @param action_url the URL of the action to open
69 * @param target the target, if any, defaults to 'current'
70 */
71-function openAction(action_url, target) {
72+function openAction(action_url, target, window_opener) {
73+ window_opener = parseInt(window_opener) || 0;
74 var $dialogs = jQuery('.action-dialog');
75 switch(target) {
76 case 'new':
77+ if(window_opener == 1) {
78+ if(jQuery('#appContent').length) {
79+ jQuery('#appContent').append(
80+ jQuery('<input>', {'type': 'hidden', 'id': 'window_opener'}).val(true)
81+ );
82+ }
83+ }
84 var $contentFrame = jQuery('<iframe>', {
85 src: action_url,
86 frameborder: 0,