Tuesday 10 January 2023

How to pass data from wizard to sql view report odoo?

 There is 2 way we can pass wizard data to SQL view ODOO. 


1 )  using context we can pass the selected value by user .

        as per below wizard view report method.


 def view_report(self):

        action = self.env["ir.actions.actions"]._for_xml_id("module_name.report_sql_view_action")

        context = {

            'start_date': self.start_date,

            'end_date': self.end_date,

        }

        # to initialise again SQL report with user new value.

        self.env["model.report"].with_context(context).init()

        return action


2 )  using init method of sql class as a passing parameter in the method.


 def view_report(self):

        action = self.env["ir.actions.actions"]._for_xml_id("module_name.report_sql_view_action")

        # to initialise again SQL report with user new value.

        self.env["model.report"].init(self.start_date, self.end_date)

        return action

No comments:

Post a Comment