[FIX] web: search view: don't crash when typing a date
Before this rev., it crashed when the user typed a date (actually, the last character of a date) in the search view (e.g. in Accounting > Customer Invoices).
This commit is contained in:
@@ -356,8 +356,7 @@ var DateField = Field.extend(/** @lends instance.web.search.DateField# */{
|
||||
|
||||
var m = moment(v, t === 'datetime' ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD');
|
||||
if (!m.isValid()) { return $.when(null); }
|
||||
var d = m.toDate();
|
||||
var date_string = field_utils.format[this.attrs.type](d, {type: t.attrs.type});
|
||||
var date_string = field_utils.format[t](m, {type: t});
|
||||
var label = _.str.sprintf(_.str.escapeHTML(
|
||||
_t("Search %(field)s at: %(value)s")), {
|
||||
field: '<em>' + _.escape(this.attrs.string) + '</em>',
|
||||
@@ -367,7 +366,7 @@ var DateField = Field.extend(/** @lends instance.web.search.DateField# */{
|
||||
facet: {
|
||||
category: this.attrs.string,
|
||||
field: this,
|
||||
values: [{label: date_string, value: d}]
|
||||
values: [{label: date_string, value: m.toDate()}]
|
||||
}
|
||||
}]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user