Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
4 Odpowiedzi
2868 Widoki

@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?

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Autor

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

Najlepsza odpowiedź

yes, just use self.(function name)

@api.multi

def yy(self):

self.xx

#codes;

        

Awatar
Odrzuć
Autor

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

Autor

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