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.
The Question has been closedby
How to inherit a class in web module? I am trying to override the function
def index(self, req, action, token):
which is under
I chose to create a new namespace as follows. Within the directory for the web addon create your own directory "myweb". Add python files __init__.py and "mycontroller.py" to the new directory. Edit the __init__.py with 'from . import mycontroller'. Back up to the web directory and edit the __init__.py file there with 'import myweb'. Now edit mycontroller.py with 'from .. import http' and 'myweb = http'. Then make a class
class MyWebController(myweb.Controller): _cp_path = '/web/myweb' @myweb.httprequest def index(self, req, action, token): """ add your modified copy of index here """
At http://mydomain/web/myweb/ you'll hit your customized index. Now you have a nice sandbox for developing your own web module without interfering with existing web module functionality. You can copy out anything you need from main.py that you might want to reuse. I found it helpful to copy Session from it so I could override authenticate and have it return certain data I required upon login. Also copy all of the imported libraries from main.py too as they are all useful if not required.
Of course you can also be lazy and just add
class MyReports(View): _cp_path = "/web/myreport"
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: 5/6/13, 10:39 AM|
|Seen: 4713 times|
|Last updated: 3/16/15, 8:10 AM|