Skip to Content
Menu
This question has been flagged
4 Replies
2488 Views

@api.multi

def xx(self):

#code;


@api.multi

def yy(self):

#codes;


Now I want to recall function "xx" in function "yy", how shall I do this?

Avatar
Discard
Best Answer

try to this code is helpful for you

def xx(self):

    a=1

    if a:

        a=a+1

    else:

        raise ValidationError("somethins wrong")

    return a


@api.multi

def yy(self):

    self.Pro_copy=self.xx

    print self.Pro_copy

output: 2

Avatar
Discard
Author

do you mean, we can't use "self.Pro_copy" in function xx?

pro_copy is a user defiend field name.self.xx function value is set to sel.pro_copy field. this is sample code.just try to understand workflow only

Best Answer

yes, just use self.(function name)

@api.multi

def yy(self):

self.xx

#codes;

        

Avatar
Discard
Author

I have tried to code like this; but xx never be executed.

Author

@api.multi

def xx(self):

raise ValidationError("somethins wrong")

@api.multi

def yy(self):

self.xx

self.Pro_copy=self.Pro

Then the code "self.Pro_copy=self.Pro" is executed but function "xx" not executed.