mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
[MIG] web_widget_float_formula: Migrate to 10.0
This commit is contained in:
committed by
Dave Lasley
parent
abfea0fff7
commit
f19ee39524
@@ -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);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user