Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
How to override method without class?
In a.py file have one method
print "Called ABC()"
In b.py i want to override a.py file's abc() method.
I clear about.
1) I am not talking about Class method override.
2) And no any class use in a.py and b.py
3) It is possible to override abc() method without class ?
Thanks in advance,
from a import abc
abc = 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
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'
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
_inherit = 'test'
Here we overrided the method abc()
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
|Asked: 12/17/14, 1:59 AM|
|Seen: 1983 times|
|Last updated: 3/16/15, 8:10 AM|