Odoo Help

2

1
4 Answers
3
Avatar

Ivan Indonesia

--Ivan--

3440
| 6 3 9
Jakarta, Indonesia
--Ivan--
Ivan Indonesia
12/17/14, 2:54 AM

from a import abc

def new_method():

    ----

abc = new_method

OR

import a

def new_method():

    ----

a.abc = new_method

it's called monkey patching.  You can search the net for other examples, but here is one: http://stackoverflow.com/questions/19545982/monkey-patching-a-class-in-another-module-in-python

2 Comments
Ben Bernard Indonesia
12/17/14, 4:14 AM

method abc is in module a

Ivan Indonesia
12/17/14, 4:41 AM

Good catch Ben. I've updated the answer.

1
Harsh Dhaduk India
12/17/14, 4:03 AM

Hi Baiju i am not talking about class method override.

Hi Ivan have other examples like monkey patching?

Hi Bole i tried that one but not working.

 

Thanks for your replay.

1 Comment
Ivan Indonesia
12/17/14, 4:10 AM

Google python monkey patch and you can get a lot of examples.

1
Avatar

Baiju KS India

--Baiju KS--
3465
| 6 5 10
Kochi, India
--Baiju KS--
ODOO technical

        I like learning new thing, especially technical thing. I am a quick learner, I can learn technical things very fast. I have good logical skill,  I have immense interest in programming.

e-mail id : baijuks@hotmail.com

Baiju KS India
12/17/14, 2:59 AM

Hi Harsh,

To override a method you have to understand the object to which that method belongs.

If method abc() belongs to class object 'test'

ie. in .py file it will be like:-

class test (osv.osv):

    _name = 'test'

    def abc():

        return True

 

If you want to override that function you have to define a class to inherit that object and then define method with same name. Eg:-

IN b.py file

class test(osv.osv):

    _inherit = 'test'

    def abc():

        return True

 

Here we overrided the method abc()

1 Comment
La Page PT, Pascal Tremblay Canada
12/27/14, 1:10 PM

Thanks a lot!

0
Avatar

Bole Croatia

--Bole--

2572
| 6 4 8
Zagreb | Karlovac, Croatia
--Bole--

there is only 10 kind of people the ones that understand binary ... and others

Bole Croatia
12/17/14, 2:52 AM

try in b.py:

import a
def ab1(self...):
   something here

a.abc = ab1

 

Ask a Question
Writer
Keep Informed
1 follower(s)
About This Community

This platform 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.

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now