In this article you will learn how to stop auto rounding of Float fields in Odoo. Sometimes we need to store values in Float field like this (1.196). But the issue is when we write this (1.196) on Float field, the internal behaviour of Float fields will convert this value or round up this value into (1.20).
How to stop auto rounding of float fields in odoo
If we will save this it converts (1.196) to (1.20). So to overcome this issue we use "digits" parameter on Float field.
Read More: How to align left Odoo fields [float, integer] in tree views
What is digits = (x, y)?
To define the precision and scale of the number we use digits parameter in Float fields. Now the question raise here what is precision and scale. The answer is precision is the total number of significant digit in the given number before and after the decimal point. And the scale is the number of digit after the decimal point. So you can say that digits = (12, 3), here you can increase the number 3 as per your need or requirement.
Read More: How to Add Domain Filter for Many2many Field in Odoo
# Fromrate = fields.Float()# Torate = fields.Float(digits=(12,3))
6 Comments
If I have a float field that is 2.17 how do I get it to go to next number 3?
ReplyDeleteif your number is 2.57 than its roundup into 3. For more detail clear you math concepts.
DeleteWhy are you not making new tutorials you are amazing teacher. A big shout-out to your team.
ReplyDeleteThanks for appreciating, we will do our best....
DeleteKeep sharing keep learning
explaination is good , but how to avoid rounding in group by
ReplyDeletei am having scenario were my company currency is bhd, hence 3 decimals, i am not able to get this in pivot view and group by
i am using odoo version 9
can you place share screen shot using some online link
Delete