Problem with thousands separator dot and accounting decimal precision zero

Bug #1158583 reported by Balint (eSolve)
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Confirmed
Low
OpenERP's Framework R&D

Bug Description

OpenERP 7.0
Rev: 8873
Module: account

The following combination of settings cause problem to enter amount between 1000 and 999999 (4-6 digits):
Decimal precision on journal entries: 0
Thousands Separator: .
Decimal Separator: ,
Separator Format: [3,3,-1]

When I try to enter a Journal Entry for example 123.010 amount to debit or credit, then save action truncate it to 123.
1.000.000 or larger amount is OK, no problem with that.

Amount examples:
Entered: 123 Stored: 123 -OK
Entered: 123.456 Stored: 123 -NOT OK
Entered: 123.456.789 Stored: 123.456.789 -OK

Amit Parik (amit-parik)
affects: openobject-addons → openobject-server
Revision history for this message
Niels Huylebroeck (red15) wrote :

You should not enter the thousands separator, the thousands seperator will be shown for larger numbers, if you enter the period it will consider this the decimal seperator and since you have -1 for rounding off to whole numbers it will round off 123.456 to 123

Revision history for this message
Balint (eSolve) (nyitraib) wrote :

It doesn't matter I enter thousands separator or not the issue is same.
If I enter 12345 to Debit field and leave the field it will show 12.345 automatically. After SAVE the value will be 12.

Changed in openobject-server:
assignee: nobody → OpenERP's Framework R&D (openerp-dev-framework)
importance: Undecided → Low
status: New → Confirmed
Revision history for this message
Balint (eSolve) (nyitraib) wrote :

I modified the web\addons\web\static\src\js\formats.js file as per the following and it seems to work. Not all thousands separator was replaced.
Please check the fix! I also attach the corrected file.

bzr diff formats.js
=== modified file 'addons/web/static/src/js/formats.js'
--- addons/web/static/src/js/formats.js 2013-04-09 14:44:14 +0000
+++ addons/web/static/src/js/formats.js 2013-04-16 16:21:21 +0000
@@ -231,6 +231,7 @@
                 throw new Error(_.str.sprintf(_t("'%s' is not a correct integer"), value));
             return tmp;
         case 'float':
+ value = instance.web.replaceall(value, instance.web._t.database.parameters.thousands_sep, "");
             var tmp = Number(value);
             if (!isNaN(tmp))
                 return tmp;
@@ -344,4 +345,21 @@
     return instance.web.round_precision(value, Math.pow(10,-decimals));
 };

+instance.web.replaceall = function(str, replace, with_this) {
+ var str_hasil = "";
+ var temp;
+
+ for(var i = 0; i < str.length; i++) {
+ if (str[i] == replace) {
+ temp = with_this;
+ }
+ else {
+ temp = str[i];
+ }
+
+ str_hasil += temp;
+ }
+ return str_hasil;
+}
+
 };

Revision history for this message
Balint (eSolve) (nyitraib) wrote :
Revision history for this message
Hung Tran (vanda6688) wrote :

Dear Balint
I had a same issue as you, after read your comment, and read the code, I delete 2 lines in web\addons\web\static\src\js\formats.js:
- if (!isNaN(tmp))
- return tmp;"
It's work fine to me.

I think this bug because this javascript code:
var tmp = Number(value);

If you have more than 2 "." in a value (1.000.000) then Number function think that just a string and remove all "." then return 1000000
But if you have only 1 "." (1.000) then Number function doesn't understand that "." is a thousands seperator but a Decimal Separator, then it return 1

After delete those code, this line is also useless "var tmp = Number(value);"
just "var tmp;" is enough

P/s: Sorry for my bad of English :D.

Revision history for this message
Mr x (adoniasv) wrote :

Is a Bug.

Change this file:

addons/web/static/js/formats.js

Find this line in function instance.web.parse_value:
```javascript
  case 'float':
     tmp = Number(value);
     if (!isNaN(tmp))
        return tmp;
```
and change for this (Coment whit //)
```javascript
 case 'float':
     //tmp = Number(value);
     //if (!isNaN(tmp))
        //return tmp;
```
is working for us

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.