[REM] python-side evaluations of contexts and domains in dashboard controller
bzr revid: xmo@openerp.com-20121126140423-waptfrxe4gbidpnv
This commit is contained in:
parent
1f65f9a6fc
commit
ec3a720728
|
@ -2,7 +2,6 @@
|
|||
from xml.etree import ElementTree
|
||||
|
||||
import openerp
|
||||
from openerp.addons.web import nonliterals
|
||||
from openerp.addons.web.controllers.main import load_actions_from_ir_values
|
||||
|
||||
class Board(openerp.addons.web.http.Controller):
|
||||
|
@ -11,16 +10,8 @@ class Board(openerp.addons.web.http.Controller):
|
|||
@openerp.addons.web.http.jsonrequest
|
||||
def add_to_dashboard(self, req, menu_id, action_id, context_to_save, domain, view_mode, name=''):
|
||||
# FIXME move this method to board.board model
|
||||
to_eval = nonliterals.CompoundContext(context_to_save)
|
||||
to_eval.session = req.session
|
||||
ctx = dict((k, v) for k, v in to_eval.evaluate().iteritems()
|
||||
if not k.startswith('search_default_'))
|
||||
ctx['dashboard_merge_domains_contexts'] = False # TODO: replace this 6.1 workaround by attribute on <action/>
|
||||
domain = nonliterals.CompoundDomain(domain)
|
||||
domain.session = req.session
|
||||
domain = domain.evaluate()
|
||||
|
||||
dashboard_action = load_actions_from_ir_values(req, 'action', 'tree_but_open', [('ir.ui.menu', menu_id)], False)
|
||||
dashboard_action = load_actions_from_ir_values(
|
||||
req, 'action', 'tree_but_open', [('ir.ui.menu', menu_id)], False)
|
||||
|
||||
if dashboard_action:
|
||||
action = dashboard_action[0][2]
|
||||
|
@ -36,7 +27,7 @@ class Board(openerp.addons.web.http.Controller):
|
|||
'name': str(action_id),
|
||||
'string': name,
|
||||
'view_mode': view_mode,
|
||||
'context': str(ctx),
|
||||
'context': str(context_to_save),
|
||||
'domain': str(domain)
|
||||
})
|
||||
column.insert(0, new_action)
|
||||
|
@ -45,6 +36,6 @@ class Board(openerp.addons.web.http.Controller):
|
|||
'user_id': req.session._uid,
|
||||
'ref_id': view_id,
|
||||
'arch': arch
|
||||
}, req.session.eval_context(req.context))
|
||||
}, req.context)
|
||||
|
||||
return False
|
||||
|
|
|
@ -375,11 +375,22 @@ instance.board.AddToDashboard = instance.web.search.Input.extend({
|
|||
var domain = new instance.web.CompoundDomain(getParent.dataset.get_domain() || []);
|
||||
_.each(data.contexts, context.add, context);
|
||||
_.each(data.domains, domain.add, domain);
|
||||
|
||||
var c = instance.web.pyeval.eval('context', context);
|
||||
for(var k in c) {
|
||||
if (c.hasOwnProperty(k) && /^search_default_/.test(k)) {
|
||||
delete c[k];
|
||||
}
|
||||
}
|
||||
// TODO: replace this 6.1 workaround by attribute on <action/>
|
||||
c.dashboard_merge_domains_contexts = false;
|
||||
var d = instance.web.pyeval.eval('domain', domain);
|
||||
|
||||
this.rpc('/board/add_to_dashboard', {
|
||||
menu_id: this.$el.find("select").val(),
|
||||
action_id: view_parent.action.id,
|
||||
context_to_save: context,
|
||||
domain: domain,
|
||||
context_to_save: c,
|
||||
domain: d,
|
||||
view_mode: view_parent.active_view,
|
||||
name: this.$el.find("input").val()
|
||||
}).done(function(r) {
|
||||
|
|
Loading…
Reference in New Issue