diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 3d1769bf345..368218b1293 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -2283,17 +2283,24 @@ display: inline-block; min-width: 70px; } -.openerp .oe_form_field_radio td, .openerp .oe_form_field_radio th { +.openerp .oe_form_field_radio.oe_horizontal { + white-space: nowrap; +} +.openerp .oe_form_field_radio.oe_horizontal .oe_radio_header { + display: inline-block; text-align: center; } +.openerp .oe_form_field_radio.oe_vertical .oe_radio_header { + cursor: pointer; +} .openerp .oe_form_field_radio .oe_radio_input { cursor: pointer; display: inline-block; width: 20px; - background: transparent url(/web/static/src/img/icons/input_radio-off.png) no-repeat 0px 0px; + background: transparent url(/web/static/src/img/icons/input_radio-off.png) no-repeat center center; } .openerp .oe_form_field_radio .oe_radio_input_on { - background: transparent url(/web/static/src/img/icons/input_radio-on.png) no-repeat 0px 0px; + background: transparent url(/web/static/src/img/icons/input_radio-on.png) no-repeat center center; } .openerp .oe_form_field_radio .oe_radio_label { cursor: default; diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index a809e77f62a..5ff3c91442f 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -477,15 +477,21 @@ $sheet-padding: 16px background: $tag-bg-dark color: #eee .oe_form_field_radio - td,th - text-align: center - .oe_radio_input + &.oe_horizontal + white-space: nowrap + .oe_radio_header + display: inline-block + text-align: center + &.oe_vertical + .oe_radio_header + cursor: pointer + .oe_radio_input { cursor: pointer display: inline-block width: 20px - background: transparent url(/web/static/src/img/icons/input_radio-off.png) no-repeat 0px 0px + background: transparent url(/web/static/src/img/icons/input_radio-off.png) no-repeat center center .oe_radio_input_on - background: transparent url(/web/static/src/img/icons/input_radio-on.png) no-repeat 0px 0px + background: transparent url(/web/static/src/img/icons/input_radio-on.png) no-repeat center center .oe_radio_label cursor: default .oe_tags diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 28d6c38fcd3..ce0f0ab23e7 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2791,72 +2791,23 @@ instance.web.form.FieldRadio = instance.web.form.AbstractField.extend(instance.w this.no_radiolabel = +node.attrs.no_radiolabel; this.display_readonly = +node.attrs.display_readonly; }, - _action_click: function ($tag, value) { + initialize_content: function () { var self = this; - $tag.on('click', $tag, function (event) { - if (!self.get("effective_readonly")) { - if (!self.field.required && value[0] == self.get_value()) { - self.set_value(undefined); + this.$el.on('click', '.oe_radio_input,.oe_radio_header', function (event) { + var id = $(event.target).data("id"); + id = isNaN(+id) ? id : +id; + if (id && !self.get("effective_readonly")) { + if (!self.field.required && id == self.get_value()) { + self.set_value(false); } else { - self.set_value(value[0]); + self.set_value(id); } } }); }, - _render_input: function (value) { - var check = value[0] == this.get_value(); - var $input = $(' '); - this._action_click($input, value); - return $input; - }, - _render_label: function (value, width) { - $label = $('