Code review comment for lp:~openerp-dev/openobject-server/6.0-opw-18123-Lorenzo_Battistini

Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

This is a very dangerous fix (res.currency is a core system object), and inappropriate given the way OpenERP uses floats rather than decimals.

Our floating point calculations are all performed with floats, and we have appropriate solutions for all cases based on floats. So for consistency, please do not introduce the use of Decimal in patches. For more info on the everlasting Float vs. Decimal discussion, see [1].

Here the problem is the equality comparison in account_voucher. For checking that 2 amounts are equal with regard to an appropriate precision, the 2 amounts should be subtracted and checked with res.currency.is_zero().
You can see other examples of how this is done in other places in the code, for example [2].

Thanks!

[1] https://lists.launchpad.net/openerp-expert-accounting/msg00067.html
[2] http://bazaar.launchpad.net/~openerp/openobject-addons/trunk/view/5493/account_voucher/account_voucher.py#L940

review: Disapprove

« Back to merge proposal