Merge lp:~openerp-dev/openobject-client-web/6.0-opw-576560-xal into lp:openobject-client-web

Proposed by Xavier ALT
Status: Merged
Merged at revision: 4856
Proposed branch: lp:~openerp-dev/openobject-client-web/6.0-opw-576560-xal
Merge into: lp:openobject-client-web
Diff against target: 77 lines (+16/-5)
2 files modified
addons/openerp/controllers/actions.py (+6/-2)
addons/openerp/static/javascript/openerp/openerp.base.js (+10/-3)
To merge this branch: bzr merge lp:~openerp-dev/openobject-client-web/6.0-opw-576560-xal
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+113923@code.launchpad.net

Description of the change

Hi,

This as missing support for "nodestroy" flag on ir.actions.act_window (on-the-fly action can use this flag to present the original wizard dialog to close).

Regards,
Xavier

To post a comment you must log in.

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 2012-06-08 15:17:28 +0000
3+++ addons/openerp/controllers/actions.py 2012-07-09 08:36:20 +0000
4@@ -350,6 +350,9 @@
5 cherrypy.response.headers['active_id'] = cherrypy.request.params.get('_terp_id')\
6 or cherrypy.request.params.context.get('active_id')
7
8+ # when action 'open a new tab', make sure we follow 'nodestroy' flag, if set.
9+ no_destroy = (action.get('nodestroy') and open_new_tab) and 'true' or 'false'
10+
11 # Add 'opened' mark to indicate we're now within the popup and can
12 # continue on during the second round of execution
13 payload = str({
14@@ -370,11 +373,12 @@
15 url = '/?' + urllib.urlencode({'next': url})
16
17 cherrypy.response.headers['X-Target'] = action['target']
18+ cherrypy.response.headers['X-No-Destroy'] = no_destroy
19 cherrypy.response.headers['Location'] = url
20 return """<script type="text/javascript">
21- window.top.openAction('%s', '%s');
22+ window.top.openAction('%s', '%s', false, %s);
23 </script>
24- """ % (url, action['target'])
25+ """ % (url, action['target'], no_destroy)
26
27 def execute(action, **data):
28 """Execute the action with the provided data. for internal use only.
29
30=== modified file 'addons/openerp/static/javascript/openerp/openerp.base.js'
31--- addons/openerp/static/javascript/openerp/openerp.base.js 2012-06-08 15:50:35 +0000
32+++ addons/openerp/static/javascript/openerp/openerp.base.js 2012-07-09 08:36:20 +0000
33@@ -111,10 +111,13 @@
34 return function (data, status, xhr) {
35 var target;
36 var active_id;
37+ var nodestroy;
38 if(xhr.getResponseHeader){
39 target = xhr.getResponseHeader('X-Target');
40+ nodestroy = xhr.getResponseHeader('X-No-Destroy');
41 active_id = xhr.getResponseHeader('active_id');
42 }
43+ nodestroy = (nodestroy && nodestroy == 'true') ? true : false;
44 if(target) {
45 var _openAction;
46 if (window.top.openAction) {
47@@ -122,7 +125,7 @@
48 } else {
49 _openAction = openAction;
50 }
51- _openAction(xhr.getResponseHeader('Location'), target, active_id);
52+ _openAction(xhr.getResponseHeader('Location'), target, active_id, nodestroy);
53 return;
54 }
55 if(url) {
56@@ -167,7 +170,7 @@
57 * @param action_url the URL of the action to open
58 * @param target the target, if any, defaults to 'current'
59 */
60-function openAction(action_url, target, terp_id) {
61+function openAction(action_url, target, terp_id, nodestroy) {
62 var $dialogs = jQuery('.action-dialog');
63 switch(target) {
64 case 'new':
65@@ -206,7 +209,11 @@
66 default:
67 openLink(action_url);
68 }
69- $dialogs.dialog('close');
70+ if (!(nodestroy && nodestroy === true)) {
71+ // close dialog only if 'nodestroy' flag is not set
72+ // (_default_ behaviour is to close the dialog)
73+ $dialogs.dialog('close');
74+ }
75 }
76 function closeAction() {
77 jQuery('.action-dialog').dialog('close');