0

I am trying to inherit ExportXlsxWriter init method but my custom code init method not calling. I want to add something in init. Anyone can help ?

from odoo.addons.web.controllers.main import ExportXlsxWriter


class CustomExportXlsxWriter(ExportXlsxWriter):

    def __init__(self, field_names, row_count=0):
        print('Local::::::::::::::::')
        super().__init__(field_names, row_count=0)
6
  • "but not able to do" means? Commented Feb 2, 2024 at 11:54
  • My custom code init method not call. Commented Feb 2, 2024 at 12:06
  • I don't see in your code that you are calling anything Commented Feb 2, 2024 at 12:13
  • I think you're mixing Odoo's business models inheritance mechanism with python inheritance. Odoo's controllers aren't business models, so you have to use monkey patching for this change (because you should never change Odoo's codebase itself). Commented Feb 2, 2024 at 12:25
  • @CZoellner Thanks for your help, Now i achieved this using this solution. ExportXlsxWriter.__init__ = new_init Commented Feb 2, 2024 at 12:59

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.