[imp] made boolean readonly-able

bzr revid: nicolas.vanhoren@openerp.com-20120316115243-7cj2mbfgp4c28q0k
This commit is contained in:
niv-openerp 2012-03-16 12:52:43 +01:00
parent 55b40f3e17
commit 089664e330
3 changed files with 8 additions and 18 deletions

View File

@ -1749,7 +1749,13 @@ openerp.web.form.FieldBoolean = openerp.web.form.AbstractField.extend({
template: 'FieldBoolean',
start: function() {
this._super.apply(this, arguments);
this.$checkbox = this.$element.click(this.on_ui_change);
this.$checkbox = $("input", this.$element);
this.$element.click(this.on_ui_change);
var check_readonly = function() {
this.$checkbox.prop('disabled', this.get("effective_readonly"));
};
this.on("change:effective_readonly", this, check_readonly);
_.bind(check_readonly, this)();
},
set_value: function(value) {
this._super.apply(this, arguments);
@ -1759,10 +1765,6 @@ openerp.web.form.FieldBoolean = openerp.web.form.AbstractField.extend({
this.value = this.$checkbox.is(':checked');
this._super.apply(this, arguments);
},
update_dom: function() {
this._super.apply(this, arguments);
this.$checkbox.prop('disabled', this.readonly);
},
focus: function($element) {
this._super($element || this.$checkbox);
}

View File

@ -67,13 +67,7 @@ openerp.web.page = function (openerp) {
/** @namespace */
openerp.web.page = {};
openerp.web.page.FieldBooleanReadonly = openerp.web.form.FieldBoolean.extend({
update_dom: function() {
this._super.apply(this, arguments);
this.$element.find('input').prop('disabled', true);
}
});
openerp.web.page.FieldSelectionReadonly = openerp.web.form.AbstractField.extend({
form_template: 'FieldChar.readonly',
init: function(view, node) {
@ -152,7 +146,6 @@ openerp.web.page = function (openerp) {
openerp.web.page.readonly = openerp.web.form.widgets.extend({
'selection' : 'openerp.web.page.FieldSelectionReadonly',
'reference': 'openerp.web.page.FieldReferenceReadonly',
'boolean': 'openerp.web.page.FieldBooleanReadonly',
'binary': 'openerp.web.page.FieldBinaryFileReadonly',
'image': 'openerp.web.page.FieldBinaryImageReaonly'
});

View File

@ -960,11 +960,6 @@
</div>
</t>
</t>
<t t-name="FieldURI.readonly">
<div>
<a href="#" class="oe_form_uri"/>
</div>
</t>
<t t-name="FieldEmail">
<t t-if="!widget.get('effective_readonly')">
<table t-attf-class="oe_form_field_#{type}" cellpadding="0" cellspacing="0" border="0" width="100%">