[FIX] search selection default value in case no default is set: select option with value 'false' if there's any

bzr revid: xmo@openerp.com-20111007082905-86zc0dzwu0bv4bwz
This commit is contained in:
Xavier Morel 2011-10-07 10:29:05 +02:00
parent 9f11dfe53c
commit 342b8e680b
1 changed files with 14 additions and 0 deletions

View File

@ -784,6 +784,20 @@ openerp.web.search.SelectionField = openerp.web.search.Field.extend(/** @lends o
var value = this.attrs.selection[index][0];
if (value === false) { return null; }
return value;
},
/**
* The selection field needs a default ``false`` value in case none is
* provided, so that selector options with a ``false`` value (convention
* for explicitly empty options) get selected by default rather than the
* first (value-holding) option in the selection.
*
* @param {Object} defaults search default values
*/
render: function (defaults) {
if (!defaults[this.attrs.name]) {
defaults[this.attrs.name] = false;
}
return this._super(defaults);
}
});
openerp.web.search.BooleanField = openerp.web.search.SelectionField.extend(/** @lends openerp.web.search.BooleanField# */{