summaryrefslogtreecommitdiff
path: root/addons/web/static/lib
diff options
context:
space:
mode:
authorMathieu Duckerts-Antoine <dam@odoo.com>2018-06-12 17:11:13 +0200
committerAdrien Dieudonne <adr@odoo.com>2018-07-06 14:09:09 +0200
commit097464de6f85020ad1e56bbc253837a7d60e47e4 (patch)
treea33c5fbe25cedfd2b0ac378b13ac2d47f38f393b /addons/web/static/lib
parent9756109e670cef01b4d475c8cb6687fecdab2cd2 (diff)
[IMP] web: easy selection of a period in filters menu
This commit allow to create easily a range of periods (related to a field of date or datetime type) to select in the filters menu. Two new attributes on elements with tag 'filter' are now usable in combination in a search view arch: - date: string. A valid field name with associated type date or datetime - default_period: string (optional). To choose in the following list: - 'today' - 'this_week' - 'this_month' (default) - 'this_quarter' - 'this_year' - 'yesterday' - 'last_week' - 'last_month' - 'last_quarter' - 'last_year' - 'last_7_days' - 'last_30_days' - 'last_365_days' Example: <filter string="Creation Date" name="period_generator" date="create_date" default_period="this_quarter"/> Note: the attribute 'domain' can not be used for such filters. The generated domains are dynamic and can be saved as such via the favorites menu.
Diffstat (limited to 'addons/web/static/lib')
-rw-r--r--addons/web/static/lib/py.js/lib/py_extras.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/addons/web/static/lib/py.js/lib/py_extras.js b/addons/web/static/lib/py.js/lib/py_extras.js
index 2bc69ece598..47aaa33685e 100644
--- a/addons/web/static/lib/py.js/lib/py_extras.js
+++ b/addons/web/static/lib/py.js/lib/py_extras.js
@@ -444,6 +444,14 @@ datetime.datetime = py.type('datetime', null, {
throw new Error('ValueError: No known conversion for ' + m);
}));
},
+ to_utc: function () {
+ var d = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second);
+ var offset = d.getTimezoneOffset();
+ var kwargs = {minutes: py.float.fromJSON(offset)};
+ var timedelta = py.PY_call(py.extras.datetime.timedelta,[],kwargs);
+ var s = tmxxx(this.year, this.month, this.day + timedelta.days, this.hour, this.minute, this.second + timedelta.seconds);
+ return datetime.datetime.fromJSON(s.year, s.month, s.day, s.hour, s.minute, s.second);
+ },
now: py.classmethod.fromJSON(function () {
var d = new Date();
return py.PY_call(datetime.datetime, [
@@ -462,6 +470,7 @@ datetime.datetime = py.type('datetime', null, {
d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(),
d.getUTCMilliseconds() * 1000]);
}),
+
combine: py.classmethod.fromJSON(function () {
var args = py.PY_parseArgs(arguments, 'date time');
return py.PY_call(datetime.datetime, [