[MERGE] forward port branch saas-14 up to c7de55dc3c
This commit is contained in:
@@ -643,13 +643,15 @@ var relativedelta = py.type('relativedelta', null, {
|
||||
this._fix();
|
||||
},
|
||||
_fix: function () {
|
||||
var self = this;
|
||||
var months = asJS(this.ops.months);
|
||||
if (Math.abs(months) > 11) {
|
||||
var s = months > 0 ? 1 : -1;
|
||||
var r = utils.divmod(months * s, 12);
|
||||
this.ops.months = py.float.fromJSON(r.mod*s);
|
||||
this.ops.years = py.float.fromJSON(
|
||||
asJS(this.ops.years) + r.div*s);
|
||||
utils.divmod(months * s, 12, function (years, months) {
|
||||
self.ops.months = py.float.fromJSON(months*s);
|
||||
self.ops.years = py.float.fromJSON(
|
||||
asJS(self.ops.years) + years*s);
|
||||
});
|
||||
}
|
||||
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')",
|
||||
pyeval.context()),
|
||||
'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('timedelta', function (assert, pyeval) {
|
||||
|
||||
Reference in New Issue
Block a user