[FIX] form selection field: don't interpret value 0 as false in the template when...
authorXavier Morel <xmo@openerp.com>
Thu, 6 Dec 2012 13:51:14 +0000 (14:51 +0100)
committerXavier Morel <xmo@openerp.com>
Thu, 6 Dec 2012 13:51:14 +0000 (14:51 +0100)
bzr revid: xmo@openerp.com-20121206135114-nuwc3wdc6zatbl3d

addons/web/static/src/js/view_form.js
addons/web/static/src/xml/base.xml

index 21c3b3f..d5feb34 100644 (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
index c272e1f..2161bc8 100644 (file)
             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>