About o2m's auto complete

Asked by Buyanbat

Dear comrades,

In v6 o2m's auto complete is very useful. That was great idea.
But It did not use any domain. Just search all on all records by typed text.

How about add fields domains?

Thanks,

Question information

Language:
English Edit question
Status:
Solved
For:
Odoo Web Client Edit question
Assignee:
No assignee Edit question
Solved by:
ksh (Axelor)
Solved:
Last query:
Last reply:
Revision history for this message
Buyanbat (buyanbat-ch) said :
#1

My Correction:

It is not about o2m. I means m2o fields.

Thanks,.

Revision history for this message
Launchpad Janitor (janitor) said :
#2

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

Revision history for this message
ksh (Axelor) (ksh-axelor) said :
#3

Hello,
      This can be achieved by following code: (not able to attach patch-file as this is Question)
      Note: Following patch code is on revno: 3920 of webclient-trunk

=== 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-22 11:18:42 +0000
@@ -470,7 +470,8 @@
     this.lastSearch = this.text.value;
     loadJSONDoc('/openerp/search/get_matched' + "?" + queryString({
         text: val,
- model: this.relation
+ model: this.relation,
+ _terp_domain: getNodeAttribute(this.field, 'domain')
     })).addCallback(this.displayResults);
     return true;
 };

Revision history for this message
Buyanbat (buyanbat-ch) said :
#4

Hi ksh,

Thanks for respond. But it could not work when domain contains any variable.
Example: domain = [('type','=',2),('parent_id','=',city)]
city is variable field.

If it fixed will become very usefull

Thanks

Revision history for this message
Best ksh (Axelor) (ksh-axelor) said :
#5

Hello,
     ohh yes, Thanks for correction.
     Here, I am giving revised solution: @sma Please test this code once again before committing to branch.

=== 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-22 12:23:30 +0000
@@ -468,10 +468,16 @@
     this.processCount++;

     this.lastSearch = this.text.value;
+ 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){
+
     loadJSONDoc('/openerp/search/get_matched' + "?" + queryString({
         text: val,
- model: this.relation
- })).addCallback(this.displayResults);
+ model: self.relation,
+ _terp_domain = obj.domain
+ })).addCallback(self.displayResults);
+ })
     return true;
 };

Revision history for this message
Buyanbat (buyanbat-ch) said :
#6

Good Morning ksh,

It works fine. Really thanks for you.
But it has syntax error.
 - _terp_domain = obj.domain
+ _terp_domain : obj.domain

I am glad work together with you

TY

Revision history for this message
Buyanbat (buyanbat-ch) said :
#7

Thanks ksh (Axelor), that solved my question.