[IMP] add view's context to m2o completion name_search
bzr revid: xmo@openerp.com-20130225165236-386r8438h4vz6fav
This commit is contained in:
parent
ece114024f
commit
6803c0048f
|
@ -1473,14 +1473,15 @@ instance.web.search.ManyToOneField = instance.web.search.CharField.extend({
|
||||||
},
|
},
|
||||||
complete: function (needle) {
|
complete: function (needle) {
|
||||||
var self = this;
|
var self = this;
|
||||||
// TODO: context
|
|
||||||
// FIXME: "concurrent" searches (multiple requests, mis-ordered responses)
|
// FIXME: "concurrent" searches (multiple requests, mis-ordered responses)
|
||||||
|
var context = instance.web.pyeval.eval(
|
||||||
|
'contexts', [this.view.dataset.get_context()]);
|
||||||
return this.model.call('name_search', [], {
|
return this.model.call('name_search', [], {
|
||||||
name: needle,
|
name: needle,
|
||||||
args: instance.web.pyeval.eval(
|
args: instance.web.pyeval.eval(
|
||||||
'domains', this.attrs.domain ? [this.attrs.domain] : []),
|
'domains', this.attrs.domain ? [this.attrs.domain] : [], context),
|
||||||
limit: 8,
|
limit: 8,
|
||||||
context: {}
|
context: context
|
||||||
}).then(function (results) {
|
}).then(function (results) {
|
||||||
if (_.isEmpty(results)) { return null; }
|
if (_.isEmpty(results)) { return null; }
|
||||||
return [{label: self.attrs.string}].concat(
|
return [{label: self.attrs.string}].concat(
|
||||||
|
|
|
@ -557,7 +557,7 @@ openerp.testing.section('completions', {
|
||||||
return [[42, "choice 1"], [43, "choice @"]];
|
return [[42, "choice 1"], [43, "choice @"]];
|
||||||
});
|
});
|
||||||
|
|
||||||
var view = {inputs: []};
|
var view = {inputs: [], dataset: {get_context: function () {}}};
|
||||||
var f = new instance.web.search.ManyToOneField(
|
var f = new instance.web.search.ManyToOneField(
|
||||||
{attrs: {string: 'Dummy'}}, {relation: 'dummy.model'}, view);
|
{attrs: {string: 'Dummy'}}, {relation: 'dummy.model'}, view);
|
||||||
return f.complete("bob")
|
return f.complete("bob")
|
||||||
|
@ -586,7 +586,7 @@ openerp.testing.section('completions', {
|
||||||
strictEqual(kwargs.name, 'bob');
|
strictEqual(kwargs.name, 'bob');
|
||||||
return [];
|
return [];
|
||||||
});
|
});
|
||||||
var view = {inputs: []};
|
var view = {inputs: [], dataset: {get_context: function () {}}};
|
||||||
var f = new instance.web.search.ManyToOneField(
|
var f = new instance.web.search.ManyToOneField(
|
||||||
{attrs: {string: 'Dummy'}}, {relation: 'dummy.model'}, view);
|
{attrs: {string: 'Dummy'}}, {relation: 'dummy.model'}, view);
|
||||||
return f.complete("bob")
|
return f.complete("bob")
|
||||||
|
@ -601,11 +601,14 @@ openerp.testing.section('completions', {
|
||||||
name: 'bob',
|
name: 'bob',
|
||||||
limit: 8,
|
limit: 8,
|
||||||
args: [['foo', '=', 'bar']],
|
args: [['foo', '=', 'bar']],
|
||||||
context: {},
|
context: {flag: 1},
|
||||||
}, "should use filtering domain");
|
}, "should use filtering domain");
|
||||||
return [[42, "Match"]];
|
return [[42, "Match"]];
|
||||||
});
|
});
|
||||||
var view = {inputs: []};
|
var view = {
|
||||||
|
inputs: [],
|
||||||
|
dataset: {get_context: function () { return {flag: 1}; }}
|
||||||
|
};
|
||||||
var f = new instance.web.search.ManyToOneField(
|
var f = new instance.web.search.ManyToOneField(
|
||||||
{attrs: {string: 'Dummy', domain: '[["foo", "=", "bar"]]'}},
|
{attrs: {string: 'Dummy', domain: '[["foo", "=", "bar"]]'}},
|
||||||
{relation: 'dummy.model'}, view);
|
{relation: 'dummy.model'}, view);
|
||||||
|
|
Loading…
Reference in New Issue