[FIX] pyeval: argspec of relativedelta

bzr revid: xmo@openerp.com-20130318105244-qkgvi69do0219lkk
This commit is contained in:
Xavier Morel
2013-03-18 11:52:44 +01:00
parent 9745c8c6c6
commit ac5008abc9
2 changed files with 13 additions and 4 deletions
+7 -4
View File
@@ -502,12 +502,15 @@ openerp.web.pyeval = function (instance) {
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, {
__init__: function () {
this.ops = py.PY_parseArgs(arguments,
'* year month day hour minute second microsecond '
+ 'years months weeks days hours minutes secondes microseconds '
+ 'weekday leakdays yearday nlyearday');
this.ops = py.PY_parseArgs(arguments, args);
},
__add__: function (other) {
if (!py.PY_isInstance(other, datetime.date)) {
+6
View File
@@ -259,6 +259,12 @@ openerp.testing.section('eval.types', {
py.eval('a + a', ctx);
}, /^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', {
dependencies: ['web.data'],