[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:
Olivier Dony 2013-03-28 13:03:37 +01:00
parent bb8918806f
commit 300d5be0e6
1 changed files with 16 additions and 14 deletions

View File

@ -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# */{ instance.web.search.NumberField = instance.web.search.Field.extend(/** @lends instance.web.search.NumberField# */{
value_from: function () { complete: function (value) {
if (!this.$el.val()) { var val = this.parse(value);
return null; if (!val || isNaN(val)) { return $.when(); }
} var label = _.str.sprintf(_.str.escapeHTML(
var val = this.parse(this.$el.val()), _t("Search %(field)s for: %(value)s")), {
check = Number(this.$el.val()); field: '<em>' + this.attrs.string + '</em>',
if (isNaN(val) || val !== check) { value: '<strong>' + _.str.escapeHTML(value) + '</strong>'});
this.$el.addClass('error'); return $.when([{
throw new instance.web.search.Invalid( label: label,
this.attrs.name, this.$el.val(), this.error_message); facet: {
} category: this.attrs.string,
this.$el.removeClass('error'); field: this,
return val; values: [{label: value, value: val}]
} }
}]);
},
}); });
/** /**
* @class * @class