This question has been flagged
1 Reply
2634 Views

Good day, 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"

obviously deleted the "< />" for this post

and so... What should i do to solve this error? Thank in advance

 

Avatar
Discard

You separate on_change and fields.function

Best Answer

You are mixing two things together a field.function and onchange method

1./ Try to look for example showing how to define a field.function

   def your_field_dot_function_name(self,cr,uid,ids,fieid_name=None,args=None,context=None):
       <<your function body for calculation>>

    "my_field":fields.function(your_field_dot_function_name,string="Some string",type="float"),

 

2./ Try to look for definition of method showing the onchange method

XML File:
 
<field name="myfield" on_change="onchange_myfield(monthwage)"/>

.Py file

def onchange_myfield(self,cr,uid,ids,monthwage,context=None):
    <<your on change function body >>
    return {'value': {}}

Hope this helps !!.

Avatar
Discard