← Back to team overview

openerp-dev-web team mailing list archive

[Merge] lp:~openerp-dev/openobject-client-web/m2o-autocomplete into lp:openobject-client-web

 

sma (Open ERP) has proposed merging lp:~openerp-dev/openobject-client-web/m2o-autocomplete into lp:openobject-client-web.

Requested reviews:
  OpenERP SA's Web Client R&D (openerp-dev-web)


- Passed context, domain for many2one autocomplete.
- Please refer bug:670899. 
-- 
https://code.launchpad.net/~openerp-dev/openobject-client-web/m2o-autocomplete/+merge/41575
Your team OpenERP R&D Team is subscribed to branch lp:~openerp-dev/openobject-client-web/m2o-autocomplete.
=== 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 11:26:19 +0000
@@ -69,6 +69,8 @@
     this.hasFocus = false;
     this.sugestionBoxMouseOver = false;
     this.selectedResult = false;
+    this.eval_domain = null;
+    this.eval_context = null;
 
     this.select_img = openobject.dom.get(name + '_select');
     this.open_img = openobject.dom.get(name + '_open');
@@ -451,6 +453,8 @@
     this.selectedResultRow = 0;
     this.numResultRows = 0;
     this.lastSearch = null;
+    this.eval_domain = null;
+    this.eval_context = null;
 };
 
 ManyToOne.prototype.doDelayedRequest = function () {
@@ -468,10 +472,27 @@
     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;
+            self.eval_context = obj.context
+            loadJSONDoc('/openerp/search/get_matched' + "?" + queryString({
+               text: val,
+               model: self.relation,
+               _terp_domain: self.eval_domain,
+               _terp_context: self.eval_context
+           })).addCallback(self.displayResults);
+        });
+    } else {
+            loadJSONDoc('/openerp/search/get_matched' + "?" + queryString({
+                text: val,
+                model: this.relation,
+                _terp_domain: this.eval_domain,
+                _terp_context: this.eval_context
+            })).addCallback(self.displayResults);
+    }
     return true;
 };
 


Follow ups