Accuracy of float values doesn't match price_accuracy

Bug #459027 reported by nrumprecht
26
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Released
Undecided
Unassigned
Odoo Web Client
Fix Released
Undecided
Unassigned

Bug Description

It's more a problem than a bug,
but if you configure openerp to have a price accuracy of 4 and you have prices for your products
like 12.4432 € and add this product to a sale order line, the price that i get through the onchange method
is rounded by the openerp web client, by the class float in openerp/validators/validator.py (digit = 2) to 12.44 €,
and that is the price added to the sale_order_line like 12.4400 €. So you cannot work with the web-client if
you've another price accuracy than 2 in the openerp web server. The digit value should be set by a config file,
or better be requestet from openerp server price_accuracy value.

Greets,

Nils Rumprecht

Revision history for this message
Ferdinand (office-chricar) wrote :

I am working on a solution for price unit here
this allows to define arbitrtry price units while retaining the default decimal digits for accountig purpose
https://code.launchpad.net/~openerp-commiter/openobject-addons/chricar_price_unit

Changed in openobject-client-web:
assignee: nobody → noz (Tiny) (noz-tiny)
Revision history for this message
Navrang Oza (noz-tiny) wrote :

Hello,

In Web-client also its working fine.
You can check by using price_accuracy parameter at server side.

But for sale order line, there are some minor changes required to solve your problem.
Here attached screenshot may help you.

Thanks.

affects: openobject-client-web → openobject-addons
Navrang Oza (noz-tiny)
Changed in openobject-addons:
assignee: noz (Tiny) (noz-tiny) → nobody
Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) wrote :

Fixed by revision 2574 <email address hidden>.
Thanks.

Changed in openobject-addons:
status: New → Confirmed
status: Confirmed → Fix Released
Revision history for this message
Omar (Pexego) (omar7r) wrote :

Hi,

Review the first post, this error it shows too in purchase.order.line, when in web client product_id_change is fired, when i select a product, it sets price_unit field to for example 1,1213 because i has price_accuracy 5, but in web client when try to show the result it shows the value rounded to 2 digits because as in the first post was said in class Float of web client is defined digit=2 as constant, then the function calls format.format_decimal(float(value) or 0.0, self.digit) and executes inside:
 v = ("%%.%df" % digits) % value. Then always in on_change event with floats will show 2 decimals. In gtk it works fine.

Thanks.

Revision history for this message
Sananaz (Open ERP) (sma-tiny) wrote :

Hello,

Its fixed in stable. Please update your code and notify us.

Revision-info:
2838 <email address hidden>

Thanks.

Changed in openobject-client-web:
status: New → Fix Committed
Revision history for this message
Omar (Pexego) (omar7r) wrote :

Hi sma,

It isn't fix. Where you write your lines, obtain the digits but the float was rounded yet to two digits then if it maintains the digits it's good but the number it's not the original. On Float() class, validators.py file inside _from_python() function it did the rounding. I think that bug it is here.

Other thing is that in Spain or other counties where float symbol is the comma not point, your lines fail, you can write for example:
values[k] = format.format_decimal(float(values[k].replace(',', '.')) or 0.0, digit or 2)

Thanks

Changed in openobject-client-web:
status: Fix Committed → New
Revision history for this message
Sananaz (Open ERP) (sma-tiny) wrote :

Hello,

Its fixed by 2839 <email address hidden>

Thanks.

Changed in openobject-client-web:
status: New → Fix Committed
status: Fix Committed → In Progress
Revision history for this message
Sananaz (Open ERP) (sma-tiny) wrote :

Hello omar,

You are right, it cant work if other countries where float symbol is the comma not point.
Now fixed that problem in stable. Please update your code and notify us.

Revision-info:
2841 <email address hidden>

Thanks for pointing out.

Navrang Oza (noz-tiny)
Changed in openobject-client-web:
status: In Progress → Fix Committed
Navrang Oza (noz-tiny)
Changed in openobject-client-web:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Bug attachments

Remote bug watches

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