调用代码中定义的函数时,我从ODOO 11工资单中调用函数时出现错误。错误消息是:“为工资规则加班工资(OT)定义了错误的python代码。”
我写的代码如下-
class SalaryRuleFunctions(models.Model):
_inherit = 'hr.payslip'
@api.multi
def get_overtime_salary(self):
emp_id = self.employee_id
dt_from = self.date_from
dt_to = self.date_to
emp_rec = self.env['x_attendance_summary'].search([('employee_id', '=', emp_id), ('start_date', '=', dt_from), ('end_date', '=', dt_to)])[0]
g_sal = (self.contract_id.x_ctc_gross / emp_rec.max_days)
o_day = emp_rec.x_overtime_days_normal
result = g_sal * o_day
return result加班工资的工资规则内代码如下:
result = payslip.env['hr.payslip'].get_overtime_salary()我不确定这个函数是否被调用过。我尝试在我的函数中添加一些消息,以了解函数代码是否有错误。但是,这些消息都没有出现,这表明该函数从未被调用过,错误是从工资规则本身抛出的。
是不是环境变量在Odoo 11中不可用?还是别的什么?
提前感谢大家的帮助。
发布于 2018-11-29 22:20:13
解决方案是使用可变合同而不是工资单。
result = contract.env['hr.payslip'].get_overtime_salary()https://stackoverflow.com/questions/51888221
复制相似问题