').done(function() {
self.datewidget.$el.addClass(self.$el.attr('class'));
self.replaceElement(self.datewidget.$el);
self.datewidget.$input.addClass('o_form_input');
self.setupFocus(self.datewidget.$input);
});
}
},
render_value: function() {
if (this.get("effective_readonly")) {
this.$el.text(formats.format_value(this.get('value'), this, ''));
} else {
this.datewidget.set_value(this.get('value'));
}
},
is_syntax_valid: function() {
return this.get("effective_readonly") || !this.datewidget || this.datewidget.is_valid();
},
is_false: function() {
return this.get('value') === '' || this._super();
},
focus: function() {
if (!this.get("effective_readonly")) {
return this.datewidget.$input.focus();
}
return false;
},
});
var FieldDatetime = FieldDate.extend({
build_widget: function() {
return new datepicker.DateTimeWidget(this);
},
});
var FieldText = common.AbstractField.extend(common.ReinitializeFieldMixin, {
template: 'FieldText',
events: {
'keyup': function (e) {
if (e.which === $.ui.keyCode.ENTER) {
e.stopPropagation();
}
},
'keypress': function (e) {
if (e.which === $.ui.keyCode.ENTER) {
e.stopPropagation();
}
},
'change': 'store_dom_value',
},
initialize_content: function() {
if (!this.get("effective_readonly")) {
this.auto_sized = false;
this.setupFocus(this.$el);
}
},
commit_value: function () {
if (!this.get("effective_readonly")) {
this.store_dom_value();
}
return this._super();
},
store_dom_value: function () {
this.internal_set_value(formats.parse_value(this.$el.val(), this));
},
render_value: function() {
if (this.get("effective_readonly")) {
var txt = this.get("value") || '';
this.$el.text(txt);
} else {
var show_value = formats.format_value(this.get('value'), this, '');
this.$el.val(show_value);
dom_utils.autoresize(this.$el, {parent: this});
}
},
is_syntax_valid: function() {
if (!this.get("effective_readonly")) {
try {
formats.parse_value(this.$el.val(), this, '');
} catch(e) {
return false;
}
}
return true;
},
is_false: function() {
return this.get('value') === '' || this._super();
},
focus: function($el) {
if(!this.get("effective_readonly")) {
return this.$el.focus();
}
return false;
},
set_dimensions: function(height, width) {
this.$el.css({
width: width,
minHeight: height,
});
},
});
var FieldBoolean = common.AbstractField.extend({
template: 'FieldBoolean',
events: {
'click': function() {
this.internal_set_value(this.$checkbox.prop('checked'));
}
},
start: function() {
this.$checkbox = this.$('input');
this.$checkbox.prop('disabled', this.get("effective_readonly"));
this.on("change:effective_readonly", this, function() {
this.$checkbox.prop('disabled', this.get("effective_readonly"));
});
this.setupFocus(this.$checkbox);
return this._super();
},
render_value: function() {
this.$checkbox.prop('checked', this.get('value'));
},
focus: function() {
return this.$checkbox.focus();
},
set_dimensions: function(height, width) {}, // Checkboxes have a fixed height and width (even in list editable)
is_false: function() {
return false;
},
});
/**
This widget is intended to be used on stat button boolean fields.
It is a read-only field that will display a simple string "