Hey there ,
Umm Trying to create a front end script report which fetches data from Opportunity Doctype to monitor the progress of the Opportunity owner with their Opportunities. It displays over all data in the report ,in this we need to achieve the data of the particular should only display when the user access to the report.
How can we apply filter using the frappe.session.user function
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
frappe.query_reports['test re'] = {
"filters": [
{
"fieldname": "opportunity_owner",
"label": "Opportunity Owner",
"fieldtype": "Data",
"default": frappe.session.user
}
]
};
Help me out with this.