diff options
Diffstat (limited to 'addons/web/static/src/js/widgets/date_picker.js')
| -rw-r--r-- | addons/web/static/src/js/widgets/date_picker.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/addons/web/static/src/js/widgets/date_picker.js b/addons/web/static/src/js/widgets/date_picker.js index 9d47e79f6a7..7220bd6efd5 100644 --- a/addons/web/static/src/js/widgets/date_picker.js +++ b/addons/web/static/src/js/widgets/date_picker.js @@ -1,10 +1,13 @@ odoo.define('web.datepicker', function (require) { "use strict"; +var core = require('web.core'); var field_utils = require('web.field_utils'); var time = require('web.time'); var Widget = require('web.Widget'); +var _t = core._t; + var DateWidget = Widget.extend({ template: "web.datepicker", type_of_date: "date", @@ -95,6 +98,9 @@ var DateWidget = Widget.extend({ if (hasChanged) { // The condition is strangely written; this is because the // values can be false/undefined + if (this.options.warn_future) { + this._warnFuture(newValue); + } this.trigger("datetime_changed"); } } @@ -139,6 +145,25 @@ var DateWidget = Widget.extend({ //-------------------------------------------------------------------------- /** + * add a warning to communicate that a date in the future has been set + * + * @private + * @param {Moment} currentDate + */ + _warnFuture: function(currentDate) { + if (!this.$warning) { + this.$warning = $('<span class="fa fa-exclamation-triangle o_tz_warning o_datepicker_warning"/>') + this.$warning.attr('title', _t("This date is on the future. Make sure it is what you expected.")) + this.$input.after(this.$warning) + } + if (currentDate.isAfter(moment())) { + this.$warning.show() + } else { + this.$warning.hide() + } + }, + + /** * @private * @param {Moment} v * @returns {string} |
