[MERGE] forward port branch 10.0 up to 72f76caa39
This commit is contained in:
@@ -627,13 +627,15 @@ var relativedelta = py.type('relativedelta', null, {
|
|||||||
this._fix();
|
this._fix();
|
||||||
},
|
},
|
||||||
_fix: function () {
|
_fix: function () {
|
||||||
|
var self = this;
|
||||||
var months = asJS(this.ops.months);
|
var months = asJS(this.ops.months);
|
||||||
if (Math.abs(months) > 11) {
|
if (Math.abs(months) > 11) {
|
||||||
var s = months > 0 ? 1 : -1;
|
var s = months > 0 ? 1 : -1;
|
||||||
var r = utils.divmod(months * s, 12);
|
utils.divmod(months * s, 12, function (years, months) {
|
||||||
this.ops.months = py.float.fromJSON(r.mod*s);
|
self.ops.months = py.float.fromJSON(months*s);
|
||||||
this.ops.years = py.float.fromJSON(
|
self.ops.years = py.float.fromJSON(
|
||||||
asJS(this.ops.years) + r.div*s);
|
asJS(self.ops.years) + years*s);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
this._has_time = 0;
|
this._has_time = 0;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -300,6 +300,14 @@ odoo.define_section('eval.types', ['web.pyeval'], function (test, mock) {
|
|||||||
py.eval("(datetime.date(2015,2,5)+relativedelta(days=-6,weekday=0)).strftime('%Y-%m-%d')",
|
py.eval("(datetime.date(2015,2,5)+relativedelta(days=-6,weekday=0)).strftime('%Y-%m-%d')",
|
||||||
pyeval.context()),
|
pyeval.context()),
|
||||||
'2015-02-02');
|
'2015-02-02');
|
||||||
|
strictEqual(
|
||||||
|
py.eval("(datetime.date(2018, 2, 1) + relativedelta(years=7, months=42, days=42)).strftime('%Y-%m-%d')",
|
||||||
|
pyeval.context()),
|
||||||
|
'2028-09-12');
|
||||||
|
strictEqual(
|
||||||
|
py.eval("(datetime.date(2018, 2, 1) + relativedelta(years=-7, months=-42, days=-42)).strftime('%Y-%m-%d')",
|
||||||
|
pyeval.context()),
|
||||||
|
'2007-06-20');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('datetime.tojson', function (assert, pyeval) {
|
test('datetime.tojson', function (assert, pyeval) {
|
||||||
|
|||||||
Reference in New Issue
Block a user