This question has been flagged
3 Replies
3712 Views

@api.onchange('r_sale')

def get_onchange(self):

        if self.r_sale:

                  obj=self.env['sale.order'].browse(self.r_sale)

                   print obj.id

This function showing Error : "  get_onchange() takes exactly 1 argument (5 given)".

This is how i defined on_change in view :<field name="r_sale" on_change="get_onchange(r_sale)"/>

What are the 5 arguments passed to the function get_onchange()? Why it shows error?




Avatar
Discard
Best Answer

You don't need to use on_change attribute in view definition for v8. And also in browse() you need to pass list of id/ids.

Try like this:

@api.onchange('r_sale')

def _get_onchange(self):

if self.r_sale:

obj=self.env['sale.order'].browse([self.r_sale.id])

print obj.id

in view:

<field name="r_sale" />;
Avatar
Discard
Author

Thank You

Best Answer

Hello Deepak Krishna,

If you are using api.onchange, then you don't have to specify the onchange in your xml.

Just remove the "on_change" (on_change="get_onchange(r_sale)") attribute from xml, update the module and try that again.

Hope this will help you.

Avatar
Discard
Author

Thank You

Best Answer

Hi Depak

You need not to specify on_change="get_onchange(r_sale)"/> in your view definiton.

I think this may be the problem.


Avatar
Discard
Author

Thank You