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

Proposed by Sananaz (Open ERP)
Status: Rejected
Rejected by: Xavier (Open ERP)
Proposed branch: lp:~openerp-dev/openobject-client-web/m2o-autocomplete
Merge into: lp:openobject-client-web/trunk
Diff against target: 52 lines (+25/-4)
1 file modified
addons/openerp/static/javascript/m2o.js (+25/-4)
To merge this branch: bzr merge lp:~openerp-dev/openobject-client-web/m2o-autocomplete
Reviewer Review Type Date Requested Status
Krisztian Eyssen (community) Approve
Xavier (Open ERP) (community) Needs Fixing
Review via email: mp+41575@code.launchpad.net

Description of the change

- Passed context, domain for many2one autocomplete.
- Please refer bug:670899.

To post a comment you must log in.
Revision history for this message
Xavier (Open ERP) (xmo-deactivatedaccount) wrote :

Please use jquery rather than mochikit apis.

review: Needs Fixing
Revision history for this message
Krisztian Eyssen (eyssen) :
review: Approve

Unmerged revisions

3929. By ksh (Axelor)

[FIX] Fixed m2o autocomplete for domain, context.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'addons/openerp/static/javascript/m2o.js'
2--- addons/openerp/static/javascript/m2o.js 2010-10-28 10:05:32 +0000
3+++ addons/openerp/static/javascript/m2o.js 2010-11-23 11:26:19 +0000
4@@ -69,6 +69,8 @@
5 this.hasFocus = false;
6 this.sugestionBoxMouseOver = false;
7 this.selectedResult = false;
8+ this.eval_domain = null;
9+ this.eval_context = null;
10
11 this.select_img = openobject.dom.get(name + '_select');
12 this.open_img = openobject.dom.get(name + '_open');
13@@ -451,6 +453,8 @@
14 this.selectedResultRow = 0;
15 this.numResultRows = 0;
16 this.lastSearch = null;
17+ this.eval_domain = null;
18+ this.eval_context = null;
19 };
20
21 ManyToOne.prototype.doDelayedRequest = function () {
22@@ -468,10 +472,27 @@
23 this.processCount++;
24
25 this.lastSearch = this.text.value;
26- loadJSONDoc('/openerp/search/get_matched' + "?" + queryString({
27- text: val,
28- model: this.relation
29- })).addCallback(this.displayResults);
30+ if (this.numResultRows==0) {
31+ var self = this;
32+ var req = eval_domain_context_request({source: this.name, domain: getNodeAttribute(this.field, 'domain'), context: getNodeAttribute(this.field, 'context')});
33+ req.addCallback(function(obj) {
34+ self.eval_domain = obj.domain;
35+ self.eval_context = obj.context
36+ loadJSONDoc('/openerp/search/get_matched' + "?" + queryString({
37+ text: val,
38+ model: self.relation,
39+ _terp_domain: self.eval_domain,
40+ _terp_context: self.eval_context
41+ })).addCallback(self.displayResults);
42+ });
43+ } else {
44+ loadJSONDoc('/openerp/search/get_matched' + "?" + queryString({
45+ text: val,
46+ model: this.relation,
47+ _terp_domain: this.eval_domain,
48+ _terp_context: this.eval_context
49+ })).addCallback(self.displayResults);
50+ }
51 return true;
52 };
53