diff options
| author | Antony Lesuisse <al@openerp.com> | 2012-06-28 16:26:40 +0200 |
|---|---|---|
| committer | Antony Lesuisse <al@openerp.com> | 2012-06-28 16:26:40 +0200 |
| commit | 8e392289a31c87ff1f586bdb5e2cf60d3631ce3a (patch) | |
| tree | f35c7acfb8fdcbc8504c52057c5b3ab7a9399bf7 /addons/web/static/src/js | |
| parent | ed4c342d9c032ceb98ef644822b4a5bf00e62acb (diff) | |
| parent | 7b0bef5bccf900100b7c463a0c3ae62f4db27064 (diff) | |
[MERGE] search many2one default create in context
bzr revid: al@openerp.com-20120628142640-kp5scu95zuy7alrw
Diffstat (limited to 'addons/web/static/src/js')
| -rw-r--r-- | addons/web/static/src/js/search.js | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/addons/web/static/src/js/search.js b/addons/web/static/src/js/search.js index 3dc8866b6b7..2e332ed8b28 100644 --- a/addons/web/static/src/js/search.js +++ b/addons/web/static/src/js/search.js @@ -1189,7 +1189,7 @@ instance.web.search.Field = instance.web.search.Input.extend( /** @lends instanc var self = this; // A field needs a context to send when active var context = this.attrs.context; - if (!context || !facet.values.length) { + if (_.isEmpty(context) || !facet.values.length) { return; } var contexts = facet.values.map(function (facetValue) { @@ -1485,6 +1485,15 @@ instance.web.search.ManyToOneField = instance.web.search.CharField.extend({ return [[name, '=', facetValue.get('value')]]; } return this._super(name, operator, facetValue); + }, + get_context: function (facet) { + var values = facet.values; + if (_.isEmpty(this.attrs.context) && values.length === 1) { + var c = {}; + c['default_' + this.attrs.name] = values.at(0).get('value'); + return c; + } + return this._super(facet); } }); |
