[MERGE] 7.0 branch
bzr revid: nicolas.vanhoren@openerp.com-20130319102859-rj9r9ngqtf5ep3a3
This commit is contained in:
commit
185b405b96
|
@ -969,7 +969,10 @@ instance.web.CompoundContext = instance.web.Class.extend({
|
||||||
},
|
},
|
||||||
get_eval_context: function () {
|
get_eval_context: function () {
|
||||||
return this.__eval_context;
|
return this.__eval_context;
|
||||||
}
|
},
|
||||||
|
eval: function() {
|
||||||
|
return instance.web.pyeval.eval('context', this, undefined, {no_user_context: true});
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
instance.web.CompoundDomain = instance.web.Class.extend({
|
instance.web.CompoundDomain = instance.web.Class.extend({
|
||||||
|
@ -992,7 +995,10 @@ instance.web.CompoundDomain = instance.web.Class.extend({
|
||||||
},
|
},
|
||||||
get_eval_context: function() {
|
get_eval_context: function() {
|
||||||
return this.__eval_context;
|
return this.__eval_context;
|
||||||
}
|
},
|
||||||
|
eval: function() {
|
||||||
|
return instance.web.pyeval.eval('domain', this);
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
instance.web.DropMisordered = instance.web.Class.extend({
|
instance.web.DropMisordered = instance.web.Class.extend({
|
||||||
|
|
|
@ -502,12 +502,15 @@ openerp.web.pyeval = function (instance) {
|
||||||
return py.PY_call(py.PY_getAttr(d, 'strftime'), [args.format]);
|
return py.PY_call(py.PY_getAttr(d, 'strftime'), [args.format]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var args = _.map(('year month day hour minute second microsecond '
|
||||||
|
+ 'years months weeks days hours minutes secondes microseconds '
|
||||||
|
+ 'weekday leakdays yearday nlyearday').split(' '), function (arg) {
|
||||||
|
return [arg, null]
|
||||||
|
});
|
||||||
|
args.unshift('*');
|
||||||
var relativedelta = py.type('relativedelta', null, {
|
var relativedelta = py.type('relativedelta', null, {
|
||||||
__init__: function () {
|
__init__: function () {
|
||||||
this.ops = py.PY_parseArgs(arguments,
|
this.ops = py.PY_parseArgs(arguments, args);
|
||||||
'* year month day hour minute second microsecond '
|
|
||||||
+ 'years months weeks days hours minutes secondes microseconds '
|
|
||||||
+ 'weekday leakdays yearday nlyearday');
|
|
||||||
},
|
},
|
||||||
__add__: function (other) {
|
__add__: function (other) {
|
||||||
if (!py.PY_isInstance(other, datetime.date)) {
|
if (!py.PY_isInstance(other, datetime.date)) {
|
||||||
|
@ -600,7 +603,7 @@ openerp.web.pyeval = function (instance) {
|
||||||
});
|
});
|
||||||
|
|
||||||
var eval_contexts = function (contexts, evaluation_context) {
|
var eval_contexts = function (contexts, evaluation_context) {
|
||||||
evaluation_context = evaluation_context || {};
|
evaluation_context = _.extend(instance.web.pyeval.context(), evaluation_context || {});
|
||||||
return _(contexts).reduce(function (result_context, ctx) {
|
return _(contexts).reduce(function (result_context, ctx) {
|
||||||
// __eval_context evaluations can lead to some of `contexts`'s
|
// __eval_context evaluations can lead to some of `contexts`'s
|
||||||
// values being null, skip them as well as empty contexts
|
// values being null, skip them as well as empty contexts
|
||||||
|
@ -625,9 +628,10 @@ openerp.web.pyeval = function (instance) {
|
||||||
// siblings
|
// siblings
|
||||||
_.extend(evaluation_context, evaluated);
|
_.extend(evaluation_context, evaluated);
|
||||||
return _.extend(result_context, evaluated);
|
return _.extend(result_context, evaluated);
|
||||||
}, _.extend({}, instance.session.user_context));
|
}, {});
|
||||||
};
|
};
|
||||||
var eval_domains = function (domains, evaluation_context) {
|
var eval_domains = function (domains, evaluation_context) {
|
||||||
|
evaluation_context = _.extend(instance.web.pyeval.context(), evaluation_context || {});
|
||||||
var result_domain = [];
|
var result_domain = [];
|
||||||
_(domains).each(function (domain) {
|
_(domains).each(function (domain) {
|
||||||
if (_.isString(domain)) {
|
if (_.isString(domain)) {
|
||||||
|
@ -654,6 +658,7 @@ openerp.web.pyeval = function (instance) {
|
||||||
return result_domain;
|
return result_domain;
|
||||||
};
|
};
|
||||||
var eval_groupbys = function (contexts, evaluation_context) {
|
var eval_groupbys = function (contexts, evaluation_context) {
|
||||||
|
evaluation_context = _.extend(instance.web.pyeval.context(), evaluation_context || {});
|
||||||
var result_group = [];
|
var result_group = [];
|
||||||
_(contexts).each(function (ctx) {
|
_(contexts).each(function (ctx) {
|
||||||
if (_.isString(ctx)) {
|
if (_.isString(ctx)) {
|
||||||
|
@ -704,14 +709,15 @@ openerp.web.pyeval = function (instance) {
|
||||||
* @param {Array} object domains or contexts to evaluate
|
* @param {Array} object domains or contexts to evaluate
|
||||||
* @param {Object} [context] evaluation context
|
* @param {Object} [context] evaluation context
|
||||||
*/
|
*/
|
||||||
instance.web.pyeval.eval = function (type, object, context) {
|
instance.web.pyeval.eval = function (type, object, context, options) {
|
||||||
|
options = options || {};
|
||||||
context = _.extend(instance.web.pyeval.context(), context || {});
|
context = _.extend(instance.web.pyeval.context(), context || {});
|
||||||
context['context'] = py.dict.fromJSON(context);
|
context['context'] = py.dict.fromJSON(context);
|
||||||
|
|
||||||
//noinspection FallthroughInSwitchStatementJS
|
//noinspection FallthroughInSwitchStatementJS
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case 'context': object = [object];
|
case 'context': object = [object];
|
||||||
case 'contexts': return eval_contexts(object, context);
|
case 'contexts': return eval_contexts((options.no_user_context ? [] : [instance.session.user_context]).concat(object), context);
|
||||||
case 'domain': object = [object];
|
case 'domain': object = [object];
|
||||||
case 'domains': return eval_domains(object, context);
|
case 'domains': return eval_domains(object, context);
|
||||||
case 'groupbys': return eval_groupbys(object, context);
|
case 'groupbys': return eval_groupbys(object, context);
|
||||||
|
|
|
@ -382,6 +382,7 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea
|
||||||
model: this.dataset._model,
|
model: this.dataset._model,
|
||||||
view_id: this.view_id,
|
view_id: this.view_id,
|
||||||
view_type: 'search',
|
view_type: 'search',
|
||||||
|
context: this.dataset.get_context(),
|
||||||
});
|
});
|
||||||
|
|
||||||
$.when(load_view).then(function (r) {
|
$.when(load_view).then(function (r) {
|
||||||
|
|
|
@ -3277,7 +3277,8 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc
|
||||||
res_model: self.field.relation,
|
res_model: self.field.relation,
|
||||||
res_id: self.get("value"),
|
res_id: self.get("value"),
|
||||||
views: [[false, 'form']],
|
views: [[false, 'form']],
|
||||||
target: 'current'
|
target: 'current',
|
||||||
|
context: self.build_context().eval(),
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
|
@ -1282,6 +1282,7 @@ instance.web.View = instance.web.Widget.extend({
|
||||||
"view_id": this.view_id,
|
"view_id": this.view_id,
|
||||||
"view_type": this.view_type,
|
"view_type": this.view_type,
|
||||||
"toolbar": !!this.options.$sidebar,
|
"toolbar": !!this.options.$sidebar,
|
||||||
|
"context": this.dataset.get_context(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return view_loaded_def.then(function(r) {
|
return view_loaded_def.then(function(r) {
|
||||||
|
@ -1496,7 +1497,7 @@ instance.web.fields_view_get = function(args) {
|
||||||
if (typeof model === 'string') {
|
if (typeof model === 'string') {
|
||||||
model = new instance.web.Model(args.model, args.context);
|
model = new instance.web.Model(args.model, args.context);
|
||||||
}
|
}
|
||||||
return args.model.call('fields_view_get', [args.view_id, args.view_type, model.context(), args.toolbar]).then(function(fvg) {
|
return args.model.call('fields_view_get', [args.view_id, args.view_type, args.context, args.toolbar]).then(function(fvg) {
|
||||||
return postprocess(fvg);
|
return postprocess(fvg);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -125,7 +125,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td><label for="super_admin_pwd">Master password:</label></td>
|
<td><label for="super_admin_pwd">Master password:</label></td>
|
||||||
<td>
|
<td>
|
||||||
<input type="text" name="super_admin_pwd" class="required" value="admin"/>
|
<input type="password" name="super_admin_pwd" class="required" value="admin"/>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
@ -259,6 +259,12 @@ openerp.testing.section('eval.types', {
|
||||||
py.eval('a + a', ctx);
|
py.eval('a + a', ctx);
|
||||||
}, /^Error: TypeError:/);
|
}, /^Error: TypeError:/);
|
||||||
});
|
});
|
||||||
|
test('relastivedelta', function (instance) {
|
||||||
|
strictEqual(
|
||||||
|
py.eval("(datetime.date(2012, 2, 15) + relativedelta(days=-1)).strftime('%Y-%m-%d 23:59:59')",
|
||||||
|
instance.web.pyeval.context()),
|
||||||
|
"2012-02-14 23:59:59");
|
||||||
|
})
|
||||||
});
|
});
|
||||||
openerp.testing.section('eval.edc', {
|
openerp.testing.section('eval.edc', {
|
||||||
dependencies: ['web.data'],
|
dependencies: ['web.data'],
|
||||||
|
|
Loading…
Reference in New Issue