[FIX] web: int/float fields were not offering auto-completion in search views, making them un-searchable except via advanced search
Added the missing complete() function and removed the incorrect value_from() override that seemed to be a leftover remnant of the 6.1 search field implementation of get_value(), wrongly renamed for 7.0. bzr revid: odo@openerp.com-20130328120337-lao4o9i0owsbpysi
This commit is contained in:
parent
bb8918806f
commit
300d5be0e6
|
@ -1346,20 +1346,22 @@ instance.web.search.CharField = instance.web.search.Field.extend( /** @lends ins
|
|||
}
|
||||
});
|
||||
instance.web.search.NumberField = instance.web.search.Field.extend(/** @lends instance.web.search.NumberField# */{
|
||||
value_from: function () {
|
||||
if (!this.$el.val()) {
|
||||
return null;
|
||||
}
|
||||
var val = this.parse(this.$el.val()),
|
||||
check = Number(this.$el.val());
|
||||
if (isNaN(val) || val !== check) {
|
||||
this.$el.addClass('error');
|
||||
throw new instance.web.search.Invalid(
|
||||
this.attrs.name, this.$el.val(), this.error_message);
|
||||
}
|
||||
this.$el.removeClass('error');
|
||||
return val;
|
||||
}
|
||||
complete: function (value) {
|
||||
var val = this.parse(value);
|
||||
if (!val || isNaN(val)) { return $.when(); }
|
||||
var label = _.str.sprintf(_.str.escapeHTML(
|
||||
_t("Search %(field)s for: %(value)s")), {
|
||||
field: '<em>' + this.attrs.string + '</em>',
|
||||
value: '<strong>' + _.str.escapeHTML(value) + '</strong>'});
|
||||
return $.when([{
|
||||
label: label,
|
||||
facet: {
|
||||
category: this.attrs.string,
|
||||
field: this,
|
||||
values: [{label: value, value: val}]
|
||||
}
|
||||
}]);
|
||||
},
|
||||
});
|
||||
/**
|
||||
* @class
|
||||
|
|
Loading…
Reference in New Issue