Browse Source

[FIX] web_widget_float_formula: Handle undefined and fix lint

* Handle undefined, or otherwise non-string parseable formula
* Fix lint issue on regex creation
pull/432/head
Dave Lasley 8 years ago
parent
commit
0852243376
No known key found for this signature in database GPG Key ID: 7DDBA4BA81B934CF
  1. 9
      web_widget_float_formula/static/src/js/web_widget_float_formula.js

9
web_widget_float_formula/static/src/js/web_widget_float_formula.js

@ -52,10 +52,15 @@ odoo.define('web_widget_float_formula', function(require) {
},
_process_formula: function(formula) {
var clean_formula = formula.toString().replace(/^\s+|\s+$/g, '');
try{
formula = formula.toString();
} catch (ex) {
return false;
}
var clean_formula = formula.replace(/^\s+|\s+$/g, '');
if (clean_formula[0] == '=') {
clean_formula = clean_formula.substring(1);
var myreg = RegExp('[0-9]|\\s|\\.|,|\\(|\\)|\\+|\\-|\\*|\\/','g');
var myreg = new RegExp('[0-9]|\\s|\\.|,|\\(|\\)|\\+|\\-|\\*|\\/', 'g');
if (clean_formula.replace(myreg, '') === '') {
return clean_formula;
}

Loading…
Cancel
Save