Odoo Help

0

TypeError: on_change_month_wage() takes at most 6 arguments (7 given)

By
Giovanny Vizcaya
on 1/19/15, 9:19 AM 1,024 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

 

You separate on_change and fields.function

Zbik
on 1/19/15, 1:33 PM
1

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 !!.

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 1/19/15, 9:19 AM
Seen: 1024 times
Last updated: 3/16/15, 8:10 AM