İçereği Atla
Menü
Bu soru işaretlendi
4 Cevaplar
2901 Görünümler

@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
Vazgeç
En İyi Yanıt

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
Vazgeç
Üretici

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

En İyi Yanıt

yes, just use self.(function name)

@api.multi

def yy(self):

self.xx

#codes;

        

Avatar
Vazgeç
Üretici

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

Üretici

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