Odoo 9:无法在工资规则中使用数学函数

Odoo 9: Unable to use math functions in Salary Rule

首先,我是 Python 初学者,现在正在学习使用 Odoo。我一直在尝试使用薪资规则中的 Python 代码汇总结果。

Payroll\Configuration\Salary 规则

我发现有一个数学函数 math.ceil() 可以对结果进行汇总。所以我编写了以下代码:

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

但我无法让它工作。我是否正确导入了数学库?

不幸的是,您不能在那里导入 python 模块,另一种方法是使用 python

中的内置 round 函数
result = round((categories.BASIC * 0.05) + 0.5)

这里我只是指定将结果四舍五入到2位,但可以是任何你想要的

#round by 100 
arl = contract.arl_wage_rate/100

base = (worked_days.TRAB100.amount+worked_days.AUSLEG.amount)*arl)

residual = (base/100) - round(base/100)

if residual > 0:
    residual = 1

else:
    residual = 0

result = (round(base/100) + residual) * 100