[FIX] form selection field: don't interpret value 0 as false in the template when the code doesn't do so

bzr revid: xmo@openerp.com-20121206135114-nuwc3wdc6zatbl3d
This commit is contained in:
Xavier Morel 2012-12-06 14:51:14 +01:00
parent 96408a36f0
commit 7ac99cbeaf
2 changed files with 8 additions and 8 deletions

View File

@ -2680,13 +2680,10 @@ instance.web.form.FieldSelection = instance.web.form.AbstractField.extend(instan
init: function(field_manager, node) {
var self = this;
this._super(field_manager, node);
this.values = _.clone(this.field.selection);
_.each(this.values, function(v, i) {
if (v[0] === false && v[1] === '') {
self.values.splice(i, 1);
}
});
this.values.unshift([false, '']);
this.values = _(this.field.selection).chain()
.reject(function (v) { return v[0] === false && v[1] === ''; })
.unshift([false, ''])
.value();
},
initialize_content: function() {
// Flag indicating whether we're in an event chain containing a change

View File

@ -1054,7 +1054,10 @@
t-att-autofocus="widget.node.attrs.autofocus"
t-att-id="widget.id_for_label">
<t t-foreach="widget.values" t-as="option">
<option><t t-esc="widget.node.attrs.placeholder" t-if="option[0] == false and widget.node.attrs.placeholder"/><t t-esc="option[1]" t-if="option[0] != false"/></option>
<option>
<t t-esc="widget.node.attrs.placeholder" t-if="option[0] === false and widget.node.attrs.placeholder"/>
<t t-esc="option[1]" t-if="option[0] !== false"/>
</option>
</t>
</select>
</span>