I am developing a payroll module adapted to Venezuelan law and I'm creating a function that seeks the daily wage of an employee, all that came out well, the module makes the calculation, but; when I want to save the log I get this error:
TypeError: on_change_month_wage() Takes at most six arguments (7 Given)
This is my code:
def on_change_month_wage(self, cr, uid, ids, month_wage, context=None):
res = {}
if month_wage > 0:
res['diary_wage'] = month_wage / 30
return {'value': res}
_columns = {
'month_wage':fields.float('Salario Mensual', digits=(16,2)),
'diary_wage':fields.function(on_change_month_wage, type = 'float', string = 'Salario Diario'),
}
and my xml lines:
<field name="month_wage" string="Salario Mensual" on_change="on_change_month_wage(month_wage)" />
<field name="diary_wage" string="Salario Diario" />
What should I do to solve this error?
It's not adviceable to use onchange method as function because on_chnage takes different argument for example:
function: This Function is return float because it's definition says type = 'float'
def cal_month_wage(self,cr,uid,ids,field_name,arg,context=None):
...
... #here your code logic
return float_value
'diary_wage':fields.function(cal_month_wage, type = 'float', string = 'Salario Diario')
onchange: Onchange return dictionary (key:value)
def on_change_month_wage(self, cr, uid, ids, month_wage, context=None):
...
... #here your code logic
return dictionary
field name="month_wage" string="Salario Mensual" on_change="on_change_month_wage(month_wage)"
Hope you get basic different on onchnage and function. After than your problem will solved.