From 300d5be0e6af4d24d09419e0be6807b265da3cd8 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Thu, 28 Mar 2013 13:03:37 +0100 Subject: [PATCH] [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 --- addons/web/static/src/js/search.js | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/addons/web/static/src/js/search.js b/addons/web/static/src/js/search.js index c1ace6b57f3..50576687808 100644 --- a/addons/web/static/src/js/search.js +++ b/addons/web/static/src/js/search.js @@ -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: '' + this.attrs.string + '', + value: '' + _.str.escapeHTML(value) + ''}); + return $.when([{ + label: label, + facet: { + category: this.attrs.string, + field: this, + values: [{label: value, value: val}] + } + }]); + }, }); /** * @class