跳至内容
菜单
此问题已终结

I want to override the report_download method in the addons/report/controllers/main.py file. but I do not know how to inherit the ReportController(Controller) class. I understand that inheriting a controller is not the same as the other classes. Can anyone please help me out?
 

形象
丢弃
最佳答案

I would suggest to do this:

 

from openerp import http
from openerp.http import request
import openerp.addons.report.controllers.main as main

class Extension(main.ReportController):

    @route(['/report/download'], type='http', auth="user")
    def report_download(self, data, token):
        do_what_you_need_to_do()
        return super(Extension, self).
report_download(data, token)

形象
丢弃
编写者

Yup, this would be a cleaner way to do it. Thanks Gael.

编写者 最佳答案

Ok got it.

from openerp.addons import report

class ReportControllerDerived(report.controllers.main.ReportController):

@route(['/report/download'], type='http', auth="user")

def report_download(self, data, token):

///remaining code

I had not referenced the base class correctly earlier

形象
丢弃
相关帖文 回复 查看 活动
0
9月 16
3621
3
11月 21
8106
1
3月 19
6817
5
6月 17
9009
5
11月 16
6868