8000 [IMP] comments from @Tardo @tarteo by quentinDupont · Pull Request #1 · legalsylvain/web · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[IMP] comments from @Tardo @tarteo #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 12.0-mig-web_widget_formula
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions web_widget_float_formula/static/src/js/web_widget_float_formula.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ odoo.define('web.web_widget_float_formula', function(require) {
var core = require('web.core');
var basic_fields = require('web.basic_fields');
var field_utils = require('web.field_utils');
var NumericField = basic_fields.FieldFloat;
var FieldFloat = basic_fields.FieldFloat;

NumericField.include({
FieldFloat.include({
_formula_text: '',

events: _.extend({
"blur": "_compute_result",
"focus": "_display_formula",
}, NumericField.prototype.events),
}, FieldFloat.prototype.events),

commitChanges: function() {
this._compute_result();
Expand All @@ -34,7 +34,7 @@ odoo.define('web.web_widget_float_formula', function(require) {
} catch (ex) {
return false;
}
var clean_formula = formula.toString().replace(/^\s+|\s+$/g, '');
var clean_formula = formula.toString().trim();
if (clean_formula[0] === '=') {
clean_formula = clean_formula.substring(1);
var myreg = new RegExp('[0-9]|\\s|\\.|,|\\(|\\)|\\+|\\-|\\*|\\/', 'g');
Expand All @@ -52,13 +52,18 @@ odoo.define('web.web_widget_float_formula', function(require) {
var thousands_sep = translation_params.thousands_sep;

var value;
if (decimal_point !== '.') {
while (formula.indexOf(decimal_point) !== -1) {
formula = formula.replace(decimal_point, '.');
}
}
formula = formula.replace(thousands_sep, '').replace(decimal_point, '.');
try {
value = eval(formula);
}
catch(e) {}

if (typeof value != 'undefined') {
if (typeof value !== 'undefined') {
return value;
}
return false;
Expand Down
0