Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

how to recall a function which is defined by myself in another function which is also defined by myself?

By
vx2008
on 7/25/16, 1:22 AM 220 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?

1
kirubanidhi
On 7/25/16, 3:37 AM

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

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

vx2008
on 7/25/16, 4:05 AM

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

kirubanidhi
on 7/27/16, 1:07 AM
1
Saravanakumar P
On 7/25/16, 2:16 AM

yes, just use self.(function name)

@api.multi

def yy(self):

self.xx

#codes;

        

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

vx2008
on 7/25/16, 3:09 AM

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

vx2008
on 7/25/16, 3:13 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 7/25/16, 1:22 AM
Seen: 220 times
Last updated: 7/28/16, 10:14 AM