[FIX] correct domain for autocomplete in many2one
authorGéry Debongnie <ged@odoo.com>
Wed, 20 Aug 2014 08:54:30 +0000 (10:54 +0200)
committerGéry Debongnie <ged@odoo.com>
Wed, 20 Aug 2014 09:55:15 +0000 (11:55 +0200)
The domain was using '=', which is correct when selecting a specific
element in autocompletion, but not when searching for all elements
matching a string.

addons/web/static/src/js/search.js

index efe4a0f..17458e1 100644 (file)
@@ -1623,7 +1623,7 @@ instance.web.search.ManyToOneField = instance.web.search.CharField.extend({
             facet: {
                 category: this.attrs.string,
                 field: this,
-                values: [{label: value, value: value}]
+                values: [{label: value, value: value, operator: 'ilike'}]
             },
             expand: this.expand.bind(this),
         }]);
@@ -1671,9 +1671,13 @@ instance.web.search.ManyToOneField = instance.web.search.CharField.extend({
         return facetValue.get('label');
     },
     make_domain: function (name, operator, facetValue) {
+        operator = facetValue.get('operator') || operator;
+
         switch(operator){
         case this.default_operator:
             return [[name, '=', facetValue.get('value')]];
+        case 'ilike':
+            return [[name, 'ilike', facetValue.get('value')]];
         case 'child_of':
             return [[name, 'child_of', facetValue.get('value')]];
         }