Skip to Content
Menu
This question has been flagged
1 Reply
7203 Views

good afternoon,

I have created a float field that will be used for tax calculations, but I have problems with rounding. what is the type of field you should select for these calculations, float or Monetary. so as not to have these errors.

For example:

def round_decimal (x):

    return x.quantize (Decimal (". 01"), rounding = ROUND_HALF_UP)

newvalue = fields.Float (string = "Others", default = 0.0)

newvalue = (price * self.quantity) * (self.invoice_line_tax_ids [0] .amount / 100)

newvalue = 7.1450

print (round_decimal (Decimal (newvalue)))

## b = 7.14

** expected 7.15

or how should I round it?

or rounding odoo taxes to two decimal places?

Thanks a lot,

Avatar
Discard
Best Answer

The data type should be determined based on the contents of the field. In this case, since tax amount is a field used to store amounts, you should define it as a monetary field.

Avatar
Discard