[FIX] Fixed float field

bzr revid: fme@openerp.com-20110509151923-vhobe1n1h0495f8t
This commit is contained in:
Fabien Meghazi 2011-05-09 17:19:23 +02:00
parent 93d7852342
commit dbe02ac106
1 changed files with 13 additions and 3 deletions

View File

@ -659,15 +659,25 @@ openerp.base.form.FieldUrl = openerp.base.form.FieldChar.extend({
openerp.base.form.FieldFloat = openerp.base.form.FieldChar.extend({
init: function(view, node) {
this._super(view, node);
this.validation_regex = /^\d+(\.\d+)?$/;
this.validation_regex = /^-?\d+(\.\d+)?$/;
},
set_value: function(value) {
this._super.apply(this, arguments);
var show_value = (value != null && value !== false) ? value.toFixed(2) : '';
if (!value) {
// As in GTK client, floats default to 0
value = 0;
}
this._super.apply(this, [value]);
var show_value = value.toFixed(2);
this.$element.find('input').val(show_value);
},
set_value_from_ui: function() {
this.value = this.$element.find('input').val().replace(/,/g, '.');
},
validate: function() {
this._super.apply(this, arguments);
if (!this.invalid) {
this.value = Number(this.value);
}
}
});