summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/fields/basic_fields.js
diff options
context:
space:
mode:
authorMichael Mattiello (mcm) <mcm@odoo.com>2020-08-03 12:17:25 +0000
committerMichael Mattiello (mcm) <mcm@odoo.com>2020-08-11 14:15:43 +0000
commita5cca2cda3b5dc9468961fe7bebeb1257d67ecdd (patch)
tree1d2aa2b4c2ffeff4c6981f9abcb725a337ab0550 /addons/web/static/src/js/fields/basic_fields.js
parent6184070923b618a6923822a2b2c37c7d9835825f (diff)
[IMP] web: add smart date input on date field
This commit adds smart date inputs for date and datetime fields. The goal of smart date input is to provide the user some shortcuts when setting dates. The rule is [+-]\d+[dwmy]? So we can enter inputs like: +3 to have today + 3 days -2w to have today - 2 weeks +1y to have today + 1 year +5m to have today + 5 months -4d to have today - 4 days closes odoo/odoo#55602 Task: 2270347 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Diffstat (limited to 'addons/web/static/src/js/fields/basic_fields.js')
-rw-r--r--addons/web/static/src/js/fields/basic_fields.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js
index 8657e44c49b..252ef70894e 100644
--- a/addons/web/static/src/js/fields/basic_fields.js
+++ b/addons/web/static/src/js/fields/basic_fields.js
@@ -863,6 +863,25 @@ var FieldDate = InputField.extend({
this.datewidget.setValue(this.value);
this.$input = this.datewidget.$input;
},
+
+ //--------------------------------------------------------------------------
+ // Handlers
+ //--------------------------------------------------------------------------
+
+ /**
+ * Confirm the value on hit enter and re-render
+ *
+ * @private
+ * @override
+ * @param {KeyboardEvent} ev
+ */
+ async _onKeydown(ev) {
+ this._super(...arguments);
+ if (ev.which === $.ui.keyCode.ENTER) {
+ await this._setValue(this.$input.val());
+ this._render();
+ }
+ },
});
var FieldDateTime = FieldDate.extend({