Skip to content

Commit ec3a720

Browse files
committed
[REM] python-side evaluations of contexts and domains in dashboard controller
bzr revid: [email protected]
1 parent 1f65f9a commit ec3a720

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

addons/board/controllers.py

+4-13
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from xml.etree import ElementTree
33

44
import openerp
5-
from openerp.addons.web import nonliterals
65
from openerp.addons.web.controllers.main import load_actions_from_ir_values
76

87
class Board(openerp.addons.web.http.Controller):
@@ -11,16 +10,8 @@ class Board(openerp.addons.web.http.Controller):
1110
@openerp.addons.web.http.jsonrequest
1211
def add_to_dashboard(self, req, menu_id, action_id, context_to_save, domain, view_mode, name=''):
1312
# FIXME move this method to board.board model
14-
to_eval = nonliterals.CompoundContext(context_to_save)
15-
to_eval.session = req.session
16-
ctx = dict((k, v) for k, v in to_eval.evaluate().iteritems()
17-
if not k.startswith('search_default_'))
18-
ctx['dashboard_merge_domains_contexts'] = False # TODO: replace this 6.1 workaround by attribute on <action/>
19-
domain = nonliterals.CompoundDomain(domain)
20-
domain.session = req.session
21-
domain = domain.evaluate()
22-
23-
dashboard_action = load_actions_from_ir_values(req, 'action', 'tree_but_open', [('ir.ui.menu', menu_id)], False)
13+
dashboard_action = load_actions_from_ir_values(
14+
req, 'action', 'tree_but_open', [('ir.ui.menu', menu_id)], False)
2415

2516
if dashboard_action:
2617
action = dashboard_action[0][2]
@@ -36,7 +27,7 @@ def add_to_dashboard(self, req, menu_id, action_id, context_to_save, domain, vie
3627
'name': str(action_id),
3728
'string': name,
3829
'view_mode': view_mode,
39-
'context': str(ctx),
30+
'context': str(context_to_save),
4031
'domain': str(domain)
4132
})
4233
column.insert(0, new_action)
@@ -45,6 +36,6 @@ def add_to_dashboard(self, req, menu_id, action_id, context_to_save, domain, vie
4536
'user_id': req.session._uid,
4637
'ref_id': view_id,
4738
'arch': arch
48-
}, req.session.eval_context(req.context))
39+
}, req.context)
4940

5041
return False

addons/board/static/src/js/dashboard.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -375,11 +375,22 @@ instance.board.AddToDashboard = instance.web.search.Input.extend({
375375
var domain = new instance.web.CompoundDomain(getParent.dataset.get_domain() || []);
376376
_.each(data.contexts, context.add, context);
377377
_.each(data.domains, domain.add, domain);
378+
379+
var c = instance.web.pyeval.eval('context', context);
380+
for(var k in c) {
381+
if (c.hasOwnProperty(k) && /^search_default_/.test(k)) {
382+
delete c[k];
383+
}
384+
}
385+
// TODO: replace this 6.1 workaround by attribute on <action/>
386+
c.dashboard_merge_domains_contexts = false;
387+
var d = instance.web.pyeval.eval('domain', domain);
388+
378389
this.rpc('/board/add_to_dashboard', {
379390
menu_id: this.$el.find("select").val(),
380391
action_id: view_parent.action.id,
381-
context_to_save: context,
382-
domain: domain,
392+
context_to_save: c,
393+
domain: d,
383394
view_mode: view_parent.active_view,
384395
name: this.$el.find("input").val()
385396
}).done(function(r) {

0 commit comments

Comments
 (0)