From 733941e97976e161f4f9188e381884fbc441f28e Mon Sep 17 00:00:00 2001 From: "Tejas (OpenERP)" Date: Tue, 22 Nov 2011 16:11:45 +0530 Subject: [PATCH] Fix search m2o field, default added bzr revid: tta@openerp.com-20111122104145-ce1z32beh8ef6346 --- addons/web/static/src/js/view_form.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 9bd1916d714..178f326f437 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2534,6 +2534,16 @@ openerp.web.form.SelectCreatePopup = openerp.web.OldWidget.extend(/** @lends ope start: function() { this._super(); var self = this; + search_defaults = {}; + if( "__contexts" in this.context.__contexts[0]) + { + _.each(this.context.__contexts[0].__contexts[0], function (value, key) { + var match = /^search_default_(.*)$/.exec(key); + if (match) { + search_defaults[match[1]] = value; + } + }); + } this.dataset = new openerp.web.ProxyDataSet(this, this.model, this.context); this.dataset.create_function = function() { @@ -2548,18 +2558,18 @@ openerp.web.form.SelectCreatePopup = openerp.web.OldWidget.extend(/** @lends ope this.dataset.parent_view = this.options.parent_view; this.dataset.on_default_get.add(this.on_default_get); if (this.options.initial_view == "search") { - this.setup_search_view(); + this.setup_search_view(search_defaults); } else { // "form" this.new_object(); } }, - setup_search_view: function() { + setup_search_view: function(search_defaults) { var self = this; if (this.searchview) { this.searchview.stop(); } this.searchview = new openerp.web.SearchView(this, - this.dataset, false, {}); + this.dataset, false, search_defaults); this.searchview.on_search.add(function(domains, contexts, groupbys) { if (self.initial_ids) { self.do_search(domains.concat([[["id", "in", self.initial_ids]], self.domain]),