Rocky Jones
Rocky Jones

Reputation: 85

Odoo Float field Rounding

I am using Odoo 10 and I cant figure out how to stop a custom float field rounding.

Here is my field box = fields.Float("Yards Per Box")

In Odoo if I put 1.196 into the field it auto rounds to 1.20 how can I stop this on a custom Float field?

Upvotes: 0

Views: 6203

Answers (3)

Rocky Jones
Rocky Jones

Reputation: 85

None of the suggested answers worked. I got it working by using dp.get_precision

here is an example

cost_price = fields.Float(
 'Book Cost', dp.get_precision('Book Price'))

Then setting Book Price in deciaml accuracy under technical to 3

This is a better way of doing it than hard coding as I can change the decimals to any figure from Odoo GUI under Technical | Database Structure | Decimal Accuracy

Upvotes: 2

VH Chaudhary
VH Chaudhary

Reputation: 84

Try this,

box = fields.Float("Yards Per Box", digits=3)

if you want to add 3 digit precision...

Upvotes: -1

aekis.dev
aekis.dev

Reputation: 2764

Try with:

box = fields.Float("Yards Per Box", digits=None)

Upvotes: 0

Related Questions