diff --git a/web_widget_float_formula/README.rst b/web_widget_float_formula/README.rst
index 092e8aed1..4804167ea 100644
--- a/web_widget_float_formula/README.rst
+++ b/web_widget_float_formula/README.rst
@@ -44,7 +44,7 @@ http://www.youtube.com/watch?v=jQGdD34WYrA.
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
- :target: https://runbot.odoo-community.org/runbot/162/9.0
+ :target: https://runbot.odoo-community.org/runbot/162/10.0
Known Issues / Roadmap
======================
diff --git a/web_widget_float_formula/__manifest__.py b/web_widget_float_formula/__manifest__.py
index ac1dec595..888b1be3d 100644
--- a/web_widget_float_formula/__manifest__.py
+++ b/web_widget_float_formula/__manifest__.py
@@ -6,7 +6,7 @@
{
'name': 'Web Widget - Formulas in Float Fields',
'summary': 'Allow use of simple formulas in float fields',
- 'version': '9.0.1.0.0',
+ 'version': '10.0.1.0.0',
'category': 'Web',
'author': 'GRAP, LasLabs, Odoo Community Association (OCA)',
'website': 'http://www.grap.coop',
@@ -17,6 +17,6 @@
'data': [
'views/web_widget_float_formula.xml',
],
- 'installable': False,
+ 'installable': True,
'application': False,
}
diff --git a/web_widget_float_formula/static/src/js/web_widget_float_formula.js b/web_widget_float_formula/static/src/js/web_widget_float_formula.js
index 76f5dd13a..065d5acf2 100644
--- a/web_widget_float_formula/static/src/js/web_widget_float_formula.js
+++ b/web_widget_float_formula/static/src/js/web_widget_float_formula.js
@@ -15,7 +15,7 @@ odoo.define('web_widget_float_formula', function(require) {
for (var f in this.fields) {
if (!this.fields.hasOwnProperty(f)) { continue; }
f = this.fields[f];
- if (f.hasOwnProperty('_formula_text')) {
+ if (f.hasOwnProperty('_formula_text') && f.$el.find('input').length > 0) {
f._compute_result();
f._clean_formula_text();
}
@@ -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() {
@@ -57,7 +58,7 @@ odoo.define('web_widget_float_formula', function(require) {
} catch (ex) {
return false;
}
- var clean_formula = formula.replace(/^\s+|\s+$/g, '');
+ var clean_formula = formula.toString().replace(/^\s+|\s+$/g, '');
if (clean_formula[0] == '=') {
clean_formula = clean_formula.substring(1);
var myreg = new RegExp('[0-9]|\\s|\\.|,|\\(|\\)|\\+|\\-|\\*|\\/', 'g');
@@ -85,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) {
@@ -100,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);
}
},
});
diff --git a/web_widget_float_formula/static/tests/js/test_web_widget_float_formula.js b/web_widget_float_formula/static/tests/js/test_web_widget_float_formula.js
index 808dd56e2..1d7b194da 100644
--- a/web_widget_float_formula/static/tests/js/test_web_widget_float_formula.js
+++ b/web_widget_float_formula/static/tests/js/test_web_widget_float_formula.js
@@ -11,8 +11,8 @@ odoo.define_section('web_widget_float_formula', ['web.form_common', 'web.form_wi
var field_manager = new form_common.DefaultFieldManager(null, {});
var filler = {'attrs': {}}; // Needed to instantiate FieldFloat
self.field = new form_widgets.FieldFloat(field_manager, filler);
- self.$element = $('');
- self.field.$el.append(self.$element);
+ self.field.$input = $('');
+ self.field.$label = $('