[ADD] Added Dataset#call_button for form's buttons triggering action that should be cleaned
bzr revid: fme@openerp.com-20110628155956-yj8m2r7kpjye5m8v
This commit is contained in:
parent
a101398751
commit
d933184dcc
|
@ -250,12 +250,12 @@ def load_actions_from_ir_values(req, key, key2, models, meta, context):
|
||||||
|
|
||||||
def clean_action(action, session):
|
def clean_action(action, session):
|
||||||
# values come from the server, we can just eval them
|
# values come from the server, we can just eval them
|
||||||
if isinstance(action['context'], basestring):
|
if isinstance(action.get('context', None), basestring):
|
||||||
action['context'] = eval(
|
action['context'] = eval(
|
||||||
action['context'],
|
action['context'],
|
||||||
session.evaluation_context()) or {}
|
session.evaluation_context()) or {}
|
||||||
|
|
||||||
if isinstance(action['domain'], basestring):
|
if isinstance(action.get('domain', None), basestring):
|
||||||
action['domain'] = eval(
|
action['domain'] = eval(
|
||||||
action['domain'],
|
action['domain'],
|
||||||
session.evaluation_context(
|
session.evaluation_context(
|
||||||
|
@ -286,13 +286,15 @@ def fix_view_modes(action):
|
||||||
if action.pop('view_type') != 'form':
|
if action.pop('view_type') != 'form':
|
||||||
return
|
return
|
||||||
|
|
||||||
action['view_mode'] = ','.join(
|
if action.has_key('view_mode'):
|
||||||
mode if mode != 'tree' else 'list'
|
action['view_mode'] = ','.join(
|
||||||
for mode in action['view_mode'].split(','))
|
mode if mode != 'tree' else 'list'
|
||||||
action['views'] = [
|
for mode in action['view_mode'].split(','))
|
||||||
[id, mode if mode != 'tree' else 'list']
|
if action.has_key('views'):
|
||||||
for id, mode in action['views']
|
action['views'] = [
|
||||||
]
|
[id, mode if mode != 'tree' else 'list']
|
||||||
|
for id, mode in action['views']
|
||||||
|
]
|
||||||
return action
|
return action
|
||||||
|
|
||||||
class Menu(openerpweb.Controller):
|
class Menu(openerpweb.Controller):
|
||||||
|
@ -440,8 +442,7 @@ class DataSet(openerpweb.Controller):
|
||||||
Model = request.session.model(model)
|
Model = request.session.model(model)
|
||||||
return Model.unlink(ids, request.session.eval_context(request.context))
|
return Model.unlink(ids, request.session.eval_context(request.context))
|
||||||
|
|
||||||
@openerpweb.jsonrequest
|
def call_common(self, req, model, method, args, domain_id=None, context_id=None):
|
||||||
def call(self, req, model, method, args, domain_id=None, context_id=None):
|
|
||||||
domain = args[domain_id] if domain_id and len(args) - 1 >= domain_id else []
|
domain = args[domain_id] if domain_id and len(args) - 1 >= domain_id else []
|
||||||
context = args[context_id] if context_id and len(args) - 1 >= context_id else {}
|
context = args[context_id] if context_id and len(args) - 1 >= context_id else {}
|
||||||
c, d = eval_context_and_domain(req.session, context, domain);
|
c, d = eval_context_and_domain(req.session, context, domain);
|
||||||
|
@ -449,10 +450,20 @@ class DataSet(openerpweb.Controller):
|
||||||
args[domain_id] = d
|
args[domain_id] = d
|
||||||
if(context_id and len(args) - 1 >= context_id):
|
if(context_id and len(args) - 1 >= context_id):
|
||||||
args[context_id] = c
|
args[context_id] = c
|
||||||
|
|
||||||
m = req.session.model(model)
|
m = req.session.model(model)
|
||||||
r = getattr(m, method)(*args)
|
return getattr(m, method)(*args)
|
||||||
return {'result': r}
|
|
||||||
|
@openerpweb.jsonrequest
|
||||||
|
def call(self, req, model, method, args, domain_id=None, context_id=None):
|
||||||
|
return {'result': self.call_common(req, model, method, args, domain_id, context_id)}
|
||||||
|
|
||||||
|
@openerpweb.jsonrequest
|
||||||
|
def call_button(self, req, model, method, args, domain_id=None, context_id=None):
|
||||||
|
action = self.call_common(req, model, method, args, domain_id, context_id)
|
||||||
|
if isinstance(action, dict) and action.get('type') != '':
|
||||||
|
clean_action(action, req.session)
|
||||||
|
return {'result': action}
|
||||||
|
|
||||||
@openerpweb.jsonrequest
|
@openerpweb.jsonrequest
|
||||||
def exec_workflow(self, req, model, id, signal):
|
def exec_workflow(self, req, model, id, signal):
|
||||||
|
|
Loading…
Reference in New Issue