bzr revid: nicolas.vanhoren@openerp.com-20110628172304-8l1kzi2dwve83dj1
This commit is contained in:
niv-openerp
2011-06-28 19:23:04 +02:00
5 changed files with 48 additions and 19 deletions
+25 -14
View File
@@ -250,12 +250,12 @@ def load_actions_from_ir_values(req, key, key2, models, meta, context):
def clean_action(action, session):
# 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'],
session.evaluation_context()) or {}
if isinstance(action['domain'], basestring):
if isinstance(action.get('domain', None), basestring):
action['domain'] = eval(
action['domain'],
session.evaluation_context(
@@ -286,13 +286,15 @@ def fix_view_modes(action):
if action.pop('view_type') != 'form':
return
action['view_mode'] = ','.join(
mode if mode != 'tree' else 'list'
for mode in action['view_mode'].split(','))
action['views'] = [
[id, mode if mode != 'tree' else 'list']
for id, mode in action['views']
]
if action.has_key('view_mode'):
action['view_mode'] = ','.join(
mode if mode != 'tree' else 'list'
for mode in action['view_mode'].split(','))
if action.has_key('views'):
action['views'] = [
[id, mode if mode != 'tree' else 'list']
for id, mode in action['views']
]
return action
class Menu(openerpweb.Controller):
@@ -440,8 +442,7 @@ class DataSet(openerpweb.Controller):
Model = request.session.model(model)
return Model.unlink(ids, request.session.eval_context(request.context))
@openerpweb.jsonrequest
def call(self, req, model, method, args, domain_id=None, context_id=None):
def call_common(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 []
context = args[context_id] if context_id and len(args) - 1 >= context_id else {}
c, d = eval_context_and_domain(req.session, context, domain);
@@ -449,10 +450,20 @@ class DataSet(openerpweb.Controller):
args[domain_id] = d
if(context_id and len(args) - 1 >= context_id):
args[context_id] = c
m = req.session.model(model)
r = getattr(m, method)(*args)
return {'result': r}
return getattr(m, method)(*args)
@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
def exec_workflow(self, req, model, id, signal):
+9
View File
@@ -328,6 +328,15 @@ openerp.base.DataSet = openerp.base.Controller.extend( /** @lends openerp.base.
args: args || []
}, callback, error_callback);
},
call_button: function (method, args, callback, error_callback) {
return this.rpc('/base/dataset/call_button', {
model: this.model,
method: method,
domain_id: null,
context_id: 1,
args: args || []
}, callback, error_callback);
},
name_get: function(ids, callback) {
return this.call_and_eval('name_get', [ids, this.context], null, 1, callback);
},
+8 -2
View File
@@ -677,12 +677,18 @@ openerp.base.form.WidgetButton = openerp.base.form.Widget.extend({
openerp.base.form.WidgetLabel = openerp.base.form.Widget.extend({
init: function(view, node) {
this.is_field_label = true;
this.element_name = 'label_' + node.attrs.name;
this._super(view, node);
this.template = "WidgetLabel";
// TODO fme: support for attrs.align
if (this.node.tag == 'label' && this.node.attrs.colspan) {
this.is_field_label = false;
this.template = "WidgetParagraph";
} else {
this.is_field_label = true;
this.template = "WidgetLabel";
}
this.colspan = 1;
},
render: function () {
+3 -3
View File
@@ -432,8 +432,8 @@ openerp.base.View = openerp.base.Controller.extend({
if (action && action.constructor == Object) {
action.context = action.context || {};
_.extend(action.context, {
active_id: dataset.ids[dataset.index],
active_ids: [dataset.ids[dataset.index]],
active_id: record_id || false,
active_ids: [record_id || false],
active_model: dataset.model
});
action.flags = {
@@ -462,7 +462,7 @@ openerp.base.View = openerp.base.Controller.extend({
var context = new openerp.base.CompoundContext(dataset.context).add(action_data.context || {});
switch(action_data.type) {
case 'object':
return dataset.call_and_eval(action_data.name, [[record_id], context], null, 1, handler);
return dataset.call_button(action_data.name, [[record_id], context], handler);
case 'action':
return this.rpc('/base/action/load', { action_id: parseInt(action_data.name, 10), context: context }, handler);
default:
+3
View File
@@ -468,6 +468,9 @@
<t t-if="widget.string and widget.node.tag != 'label'">:</t>
</label>
</t>
<t t-name="WidgetParagraph">
<p class="oe_form_paragraph"><t t-esc="widget.string"/></p>
</t>
<t t-name="FieldChar">
<input type="text"
t-att-name="widget.name"