float precision

Bug #352471 reported by Eduard Carreras i Nadal
2
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Invalid
Undecided
Unassigned

Bug Description

When you define a fields.float('Field', digits(13,12)) the value inserted in de database is a float with 6 precision.
This occurs because de _symbol_c = %f has only 6 decimal precision.
_symbol_c should get the precision of the digits parametter.

The attached patch solves the problem.

Revision history for this message
Eduard Carreras i Nadal (ecarreras) wrote :
Revision history for this message
Husen Daudi (husendaudi) wrote :

Hello,

It seems like everything is working fine.

I have defined one field in class as
'fees':fields.float('Fees',digits=(13,12)),

In database I am getting
 fees | numeric(13,12) |

and in database table value is

 select * from student_student;
| address_id | name | roll_no | fees
----+------------+--------------------------+----------------------------+-----------+------------+-------+---------+----------------
| 2 | husen | 1 | 1.111111111110

can you please check it again by creating new database?

Thanks.

Changed in openobject-server:
status: New → Invalid
Revision history for this message
Eduard Carreras i Nadal (ecarreras) wrote :

Have you inserted the value of fees directly with sql command or using pooler with create method ??, OpenERP defines well the field in the database, but float precision in the insertion method is 6...

You can try in a python console:

'%f' %0.000125430123 (precision 6: 0.000125)

'%.12f' %0.000125430123 (precision 12: 0.000125430123)

Revision history for this message
Eduard Carreras i Nadal (ecarreras) wrote :

For more information you can see in the Python Documentation Page[1], under string formatting operations section, the note number 3, which says exactly:
"The alternate form causes the result to always contain a decimal point, even if no digits follow it.
The precision determines the number of digits after the decimal point and defaults to 6."

[1] http://docs.python.org/library/stdtypes.html#string-formatting-operations

Revision history for this message
Eduard Carreras i Nadal (ecarreras) wrote :

I think 'Invalid' status should be set when the discussion was finished.

Changed in openobject-server:
status: Invalid → New
Revision history for this message
Eduard Carreras i Nadal (ecarreras) wrote :

Any news about this issue?

Revision history for this message
Fabien (Open ERP) (fp-tinyerp) wrote :

applied in branches/5.0
we periodically merge fixes from branches/5.0 to trunk

Changed in openobject-server:
status: New → Fix Released
Revision history for this message
Fabien (Open ERP) (fp-tinyerp) wrote :

Your fix is invalid. It makes the system crash (tested on tasks creation).
Hda seems to be right, it currently works with high precisions.

%f is not anymore used in openerp server, psycopg2 requires %s.

Changed in openobject-server:
status: Fix Released → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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