From f05e5922fbf4fcbbee3e7d9e2f198b5c3c005ce2 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Fri, 2 Jan 2015 17:15:08 +0100 Subject: [PATCH] [FIX][IMP] web: radio button: small fix / imp, removing an unnecessary check on the value in the code. Indeed this could prevent from putting the radio button on a selection field holding a 0 integer as selection value. --- addons/web/static/src/js/view_form.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 4f8fc48094c..c06c50ceea4 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -3268,14 +3268,13 @@ instance.web.form.FieldRadio = instance.web.form.AbstractField.extend(instance.w }); }, set_value: function (value_) { - if (value_) { - if (this.field.type == "selection") { - value_ = _.find(this.field.selection, function (sel) { return sel[0] == value_;}); - } - else if (!this.selection.length) { - this.selection = [value_]; - } + if (this.field.type == "selection") { + value_ = _.find(this.field.selection, function (sel) { return sel[0] == value_;}); } + else if (!this.selection.length) { + this.selection = [value_]; + } + this._super(value_); }, get_value: function () { @@ -3285,10 +3284,8 @@ instance.web.form.FieldRadio = instance.web.form.AbstractField.extend(instance.w render_value: function () { var self = this; this.$el.toggleClass("oe_readonly", this.get('effective_readonly')); - if (this.get_value()) { - this.$("input").filter(function () {return this.value == self.get_value();}).prop("checked", true); - this.$(".oe_radio_readonly").text(this.get('value') ? this.get('value')[1] : ""); - } + this.$("input").filter(function () {return this.value == self.get_value();}).prop("checked", true); + this.$(".oe_radio_readonly").text(this.get('value') ? this.get('value')[1] : ""); } });