From 30783c7a4359aebc6d5c2e9f9b3f3287d11c2001 Mon Sep 17 00:00:00 2001 From: fka-odoo Date: Wed, 12 Apr 2017 19:13:02 +0530 Subject: [IMP] web: Time(hours,minutes,seconds) should be calculate using timedelta with datetime on web client, added test cases for pyeval datetime.timedelta --- addons/web/static/src/js/framework/pyeval.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'addons/web/static/src/js/framework/pyeval.js') diff --git a/addons/web/static/src/js/framework/pyeval.js b/addons/web/static/src/js/framework/pyeval.js index bcab0b0717f..c1b823ed48f 100644 --- a/addons/web/static/src/js/framework/pyeval.js +++ b/addons/web/static/src/js/framework/pyeval.js @@ -436,6 +436,22 @@ datetime.datetime = py.type('datetime', null, { this.second, this.microsecond / 1000); }, + __add__: function (other) { + if (!py.PY_isInstance(other, datetime.timedelta)) { + return py.NotImplemented; + } + var s = tmxxx(this.year, this.month, this.day + other.days, this.hour, this.minute, this.second + other.seconds); + return datetime.datetime.fromJSON(s.year, s.month, s.day, s.hour, s.minute, s.second); + }, + __sub__: function (other) { + if (py.PY_isInstance(other, datetime.timedelta)) { + return py.PY_add(this, py.PY_negative(other)); + } + return py.NotImplemented; + }, + fromJSON: function (year, month, day, hour, minute, second) { + return py.PY_call(datetime.datetime, [year, month, day, hour, minute, second]); + }, }); datetime.date = py.type('date', null, { -- cgit v1.2.3