This question has been flagged
1 Reply
2156 Views

Hi All

Suppose if I override onchange_partner_id from sale order we are using 

Res=super(salesorder,self).onchange_partner_id()

Here I am adding my custom code......

Return res

Here what is the usage and meaning of res?

Can anybody tell this ?

Avatar
Discard
Best Answer

Hello, 
Overriding any function means you have replaced that old function with your new function. Now, there is mostly some important things to be performed by default function. So, we have to call the Super method which calls the original method from which you have override your new function. Now usually, original function will return you some values that you need to return from your new function as not to break the cycle. Consider one function which was calling your original function and get some computed values as output. Now, if we are overriding that function, all control will go to our new function only, the new function will responsible to manage the proper input and output of the data. That it why we need to:

1. Call Super function
2. Take the output of super function (res)
3. Make our custom computation
4. return the value(res or new-res)
Avatar
Discard
Author

Thanks ..for explanation

Good explanation +1