Tejas Tank (OpenERP) has proposed merging 
lp:~openerp-dev/openerp-web/trunk-polish3-search-m2o-auto-search-tta into 
lp:openerp-web.

Requested reviews:
  Amit (Open ERP) (apa-tiny)

For more details, see:
https://code.launchpad.net/~openerp-dev/openerp-web/trunk-polish3-search-m2o-auto-search-tta/+merge/84468

Hello,


# many2one field with web client.

   When we create PO, on supplier selection only supplier need to suggest.

   [THE DEFAULT SEARCH SHOULD BE SE ALSO IN THE SELECTION OF THE M2O] As per 
the pad.



Thanks,
Tejas - TTA

-- 
https://code.launchpad.net/~openerp-dev/openerp-web/trunk-polish3-search-m2o-auto-search-tta/+merge/84468
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openerp-web/trunk-polish3-search-m2o-auto-search-tta.
=== modified file 'addons/web/static/src/js/view_form.js'
--- addons/web/static/src/js/view_form.js	2011-12-05 09:48:38 +0000
+++ addons/web/static/src/js/view_form.js	2011-12-05 13:38:35 +0000
@@ -1831,7 +1831,35 @@
         var isSelecting = false;
         // autocomplete
         this.$input.autocomplete({
-            source: function(req, resp) { self.get_search_result(req, resp); },
+            source: function(req, resp) { 
+
+               if(self.build_domain().__ref=="compound_domain")
+                  self.get_search_result(false,req, resp); 
+               else 
+                  self.rpc('/web/session/eval_domain_and_context', {
+                        domains: []  ,
+                        contexts: [self.build_context()],
+                      }, function (results) {                          
+                      var search_defaults = {};
+                      _.each(results.context, function (value, key) {
+                          var match = /^search_default_(.*)$/.exec(key);
+                          if (match) {
+                             search_defaults[match[1]] = value;
+                            }
+                      });
+                             
+                      var temp_slice=new Array();
+                      _.each(search_defaults, function(num,key){ 
+                           temp_slice.push([key,"=",search_defaults[key]]);
+                      }); 
+                      self.__domain=temp_slice;
+                     _.each(self.build_domain(), function(num,key){ 
+                            self.__domain.push(num);
+                     });                     
+                     self.get_search_result(self.__domain,req, resp); 
+                   });    
+            
+             },
             select: function(event, ui) {
                 isSelecting = true;
                 var item = ui.item;
@@ -1861,13 +1889,14 @@
         });
     },
     // autocomplete component content handling
-    get_search_result: function(request, response) {
+    get_search_result: function(domain,request, response) {
         var search_val = request.term;
         var self = this;
 
         var dataset = new openerp.web.DataSetStatic(this, this.field.relation, self.build_context());
-
-        dataset.name_search(search_val, self.build_domain(), 'ilike',
+        if(!domain)
+            domain = self.build_domain();
+        dataset.name_search(search_val, domain, 'ilike',
                 this.limit + 1, function(data) {
             self.last_search = data;
             // possible selections for the m2o

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to