Front End Script Report - frappe.session.user

Hey there, :roll_eyes:
I have created a front end script report with Is Standard as ‘No’. Here I am just fetching the data against the Opportunity owners in the Opportunity doctype .I have fetched the data through query but it displays every users data in the report .When I try to filter the data using frappe.session.user I cannot able to achieve the expected. Attaching script and filter script for reference

Report Script

message = "test Opportunity report"

columns = [
 {
        'fieldname': 'name',

        'label': _('ID'),

        'fieldtype': 'Data',

        'options': 'Opportunity',

        'width': 200

    },
    {
        'fieldname': 'opportunity_owner',

        'label': _('Opportunity Owner'),

        'fieldtype': 'Data',
        
        'width': 200

    },
     {

        'fieldname': 'party_name',

        'label': _('Lead'),

        'fieldtype': 'Link',
        'options': 'Lead ',

        'align': 'left',

        'width': 200
    },
]
mydata = """SELECT 
o.name AS  "name",
o.opportunity_owner AS "opportunity_owner",
o.party_name AS "party_name"
FROM
`tabOpportunity` o
 """  

data=frappe.db.sql(mydata,as_dict=True)
data = columns , data , message ,None , None

Filter Script

frappe.query_reports['test re'] = {
    "filters": [
        {
            "fieldname": "opportunity_owner",
            "label": "Opportunity Owner",
            "fieldtype": "Data",
            "default": frappe.session.user // Automatically filters by the logged-in user
        }
    ]
};

Filter is applying for default value but not filtering data as expected
I need to filter opportunity_owner data with the frappe.session.user

Help me out with this I’m stuck here.

Try below

opportunity_owner = filters.get(‘opportunity_owner’) or frappe.session.user

mydata = frappe.db.sql(“”"
SELECT
o.name AS name,
o.opportunity_owner AS opportunity_owner,
o.party_name AS party_name
FROM
tabOpportunity o
WHERE
o.opportunity_owner = %s
“”", (opportunity_owner,), as_dict=True)

I am getting this below Indentation error

That filter should works like this mydata = “”“SELECT
o.name AS “name”,
o.opportunity_owner AS “opportunity_owner”,
o.party_name AS “party_name”
FROM
tabOpportunity o
WHERE
opportunity_owner = %(opportunity_owner)s
“””

I think so