[MIG] web_widget_float_formula: Migrate to 10.0

This commit is contained in:
Kelly Lougheed
2017-01-11 18:34:36 -08:00
committed by Dave Lasley
parent abfea0fff7
commit f19ee39524
6 changed files with 28 additions and 19 deletions

View File

@@ -35,9 +35,10 @@ odoo.define('web_widget_float_formula', function(require) {
var field_float = require('web.form_widgets').FieldFloat;
field_float.include({
start: function() {
this._super();
this.on('blurred', this, this._compute_result);
this.on('focused', this, this._display_formula);
return this._super();
return this;
},
initialize_content: function() {
@@ -52,6 +53,11 @@ odoo.define('web_widget_float_formula', function(require) {
},
_process_formula: function(formula) {
try{
formula = formula.toString();
} catch (ex) {
return false;
}
var clean_formula = formula.toString().replace(/^\s+|\s+$/g, '');
if (clean_formula[0] == '=') {
clean_formula = clean_formula.substring(1);
@@ -80,7 +86,9 @@ odoo.define('web_widget_float_formula', function(require) {
_compute_result: function() {
this._clean_formula_text();
var formula = this._process_formula(this.$el.find('input').val());
var input = this.$input.val();
var formula = this._process_formula(input);
if (formula !== false) {
var value = this._eval_formula(formula);
if (value !== false) {
@@ -95,7 +103,7 @@ odoo.define('web_widget_float_formula', function(require) {
// Display the formula stored in the field to allow modification
_display_formula: function() {
if (this._formula_text !== '') {
this.$el.find('input').val(this._formula_text);
this.$input.val(this._formula_text);
}
},
});