revivenote - 9 months ago 63

Python Question

First of all, I'm a Python beginner and learning to use Odoo now. I have been trying roundup the result using Python Code in Salary Rule.

Payroll\Configuration\Salary Rules

I found out there is a math function of math.ceil() to roundup the result. So I code the code below:

`import math`

result = math.ceil(categories.BASIC * 0.05)

But I couldn't get it to work. Did I import the math library correctly?

Answer Source

Unfortunately you can't import python modules there, an alternative is to use the inbuilt `round`

function in python

```
result = round((categories.BASIC * 0.05) + 0.5)
```

Here i just specified to round the result to 2 digits but it can be anything you want