=== modified file 'addons/openerp/static/javascript/m2o.js' --- addons/openerp/static/javascript/m2o.js 2010-10-28 10:05:32 +0000 +++ addons/openerp/static/javascript/m2o.js 2010-11-23 06:35:07 +0000 @@ -69,6 +69,7 @@ this.hasFocus = false; this.sugestionBoxMouseOver = false; this.selectedResult = false; + this.eval_domain = null; this.select_img = openobject.dom.get(name + '_select'); this.open_img = openobject.dom.get(name + '_open'); @@ -450,6 +451,7 @@ // Clear out our result tracking this.selectedResultRow = 0; this.numResultRows = 0; + this.eval_domain = null; this.lastSearch = null; }; @@ -468,10 +470,25 @@ this.processCount++; this.lastSearch = this.text.value; - loadJSONDoc('/openerp/search/get_matched' + "?" + queryString({ - text: val, - model: this.relation - })).addCallback(this.displayResults); + + if (this.numResultRows==0) { + var self = this; + var req = eval_domain_context_request({source: this.name, domain: getNodeAttribute(this.field, 'domain'), context: getNodeAttribute(this.field, 'context')}); + req.addCallback(function(obj) { + self.eval_domain = obj.domain; + loadJSONDoc('/openerp/search/get_matched' + "?" + queryString({ + text: val, + model: self.relation, + _terp_domain: self.eval_domain + })).addCallback(self.displayResults); + }); + } else { + loadJSONDoc('/openerp/search/get_matched' + "?" + queryString({ + text: val, + model: this.relation, + _terp_domain: this.eval_domain + })).addCallback(self.displayResults); + } return true; };