Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
16316 มุมมอง

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

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
0
ก.ย. 16
3640
3
พ.ย. 21
8157
1
มี.ค. 19
6827
5
มิ.ย. 17
9029
5
พ.ย. 16
6878