Merge lp:~openerp-dev/openobject-client-web/listview-button-action into lp:openobject-client-web/trunk

Proposed by Vaibhav Darji
Status: Merged
Merge reported by: Fabien Meghazi (OpenERP)
Merged at revision: not available
Proposed branch: lp:~openerp-dev/openobject-client-web/listview-button-action
Merge into: lp:openobject-client-web/trunk
Diff against target: 122 lines (+40/-23) (has conflicts)
2 files modified
addons/openerp/controllers/listgrid.py (+16/-21)
addons/openerp/static/javascript/listgrid.js (+24/-2)
Text conflict in addons/openerp/static/javascript/listgrid.js
To merge this branch: bzr merge lp:~openerp-dev/openobject-client-web/listview-button-action
Reviewer Review Type Date Requested Status
Fabien Meghazi (OpenERP) Approve
Review via email: mp+43200@code.launchpad.net

Description of the change

Improved ListView's button action
Working perfect using doLoadingSuccess except 1 case where:
 button is used to change the state and reload the list to reflect changed state.(Ex:Sales > Opportunities > Any record > Click on any Stage button/img)
In this case only `True` is written and no target in xhr and no url.
So doLoadingSuccess can't handle this case.

To post a comment you must log in.
4072. By Fabien Meghazi (OpenERP)

[REM] Removed console.log debugging

Revision history for this message
Fabien Meghazi (OpenERP) (fme) wrote :

Ok vda, you can merge it.

review: Approve
Revision history for this message
Fabien Meghazi (OpenERP) (fme) wrote :

Your branch is now merged in trunk

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'addons/openerp/controllers/listgrid.py'
2--- addons/openerp/controllers/listgrid.py 2010-11-24 09:57:01 +0000
3+++ addons/openerp/controllers/listgrid.py 2010-12-14 13:56:50 +0000
4@@ -308,7 +308,6 @@
5 @expose('json')
6 def button_action(self, **kw):
7 params, data = TinyDict.split(kw)
8-
9 error = None
10 reload = (params.context or {}).get('reload', False)
11 result = {}
12@@ -326,21 +325,24 @@
13 try:
14
15 if btype == 'workflow':
16- rpc.session.execute('object', 'exec_workflow', model, name, id)
17+ res = rpc.session.execute('object', 'exec_workflow', model, name, id)
18+ if isinstance(res, dict):
19+ import actions
20+ return actions.execute(res, ids=[id])
21+ else:
22+ return True
23
24 elif btype == 'object':
25 ctx = params.context or {}
26 ctx.update(rpc.session.context.copy())
27 res = rpc.session.execute('object', 'execute', model, name, ids, ctx)
28-
29- if isinstance(res, dict) and res.get('type'):
30- if res['type'] == 'ir.actions.act_url':
31- result = res
32- elif res['type'] == 'ir.actions.act_window':
33- import actions
34- res = actions.execute(res)
35- return dict(res = res)
36-
37+
38+ if isinstance(res, dict):
39+ import actions
40+ return actions.execute(res, ids=[id])
41+ else:
42+ return True
43+
44 elif btype == 'action':
45 import actions
46
47@@ -352,19 +354,12 @@
48 cherrypy.session['wizard_parent_params'] = params
49
50 res = actions.execute_by_id(action_id, type=action_type, model=model, id=id, ids=ids, context=ctx or {})
51- if isinstance(res, dict) and res.get('type') == 'ir.actions.act_url':
52- result = res
53- elif isinstance(res, basestring):
54- return dict(res = res)
55- else:
56- error = "Button action has returned another view.."
57+ return res or True
58
59 else:
60- error = "Unallowed button type"
61+ return dict(error = "Unallowed button type")
62 except Exception, e:
63- error = ustr(e)
64-
65- return dict(error=error, result=result, reload=reload)
66+ return dict(error = ustr(e))
67
68 @expose('json', methods=('POST',))
69 def groupbyDrag(self, model, children, domain):
70
71=== modified file 'addons/openerp/static/javascript/listgrid.js'
72--- addons/openerp/static/javascript/listgrid.js 2010-12-09 11:58:06 +0000
73+++ addons/openerp/static/javascript/listgrid.js 2010-12-14 13:56:50 +0000
74@@ -443,10 +443,10 @@
75 if (sure && !confirm(sure)) {
76 return;
77 }
78-
79+
80 var self = this;
81+ var _list = this.name;
82 var prefix = this.name == '_terp_list' ? '' : this.name + '/';
83-
84 if (btype == "open") {
85 return window.open(get_form_action('/openerp/form/edit', {
86 id: id,
87@@ -469,6 +469,7 @@
88 _terp_button_type : btype
89 };
90
91+<<<<<<< TREE
92 eval_domain_context_request({
93 source: this.name,
94 context : context || '{}',
95@@ -504,6 +505,27 @@
96 self.reload();
97 }
98 });
99+=======
100+ var req = eval_domain_context_request({source: this.name, context : context || '{}',active_id: id, active_ids: openobject.dom.get(prefix + '_terp_ids').value});
101+ req.addCallback(function(res) {
102+ var $form = jQuery('#listgrid_button_action');
103+ params['_terp_context'] = res.context || '{}';
104+ if($form.length) {
105+ $form.remove();
106+ }
107+ var $form = jQuery('<form>', {
108+ 'id': 'listgrid_button_action',
109+ 'name': 'listgrid_button_action',
110+ 'action':'/openerp/listgrid/button_action',
111+ 'method': 'post',
112+ 'enctype': 'multipart/form-data'
113+ }).appendTo(document.documentElement);
114+ $form.ajaxSubmit({
115+ data: params,
116+ success: doLoadingSuccess(jQuery('#appContent')),
117+ error: loadingError()
118+ });
119+>>>>>>> MERGE-SOURCE
120 });
121 }
122 });