ello everyone,
I’m trying to create a dynamic supplier dashboard in a custom Frappe app. I’ve followed the standard documentation, but I’m facing a persistent issue where a specific button is not rendering on the page.
Here’s my setup:
- Custom DocType: I have a
Supplier Product Proposal
DocType. - Web Form: I have a
Web Form
for submitting new proposals, withLogin required
checked. - User & Roles: I have assigned the
Supplier
role to theAdministrator
user. I have also linked thisAdministrator
user to a specificSupplier
DocType via thePortal Users
child table. - Web Page & Controller: I created a
Web Page
with the route/supplier-dashboard
. It’s intended to be a dynamic page that shows a list of the supplier’s proposals and a button to submit a new one.
The Problem:
The dashboard page loads correctly with the user’s name and the table headers, but the “Ajukan Produk Baru” button is not visible.
I have identified that the button is controlled by this Jinja condition: {% if add_proposal_link %}
. This variable should be set to True
by my Python controller.
My Code (supplier_dashboard.py
):
I have a Python controller in apps/marketplace_app/marketplace_app/www/supplier_dashboard.py
with this get_context
function:
def get_context(context):
if frappe.session.user == "Guest":
frappe.redirect_to("/login")
return
supplier_link = frappe.get_all("Supplier Portal User", filters={
"user": frappe.session.user
}, fields=["parent"])
if not supplier_link:
context.proposals = []
context.add_proposal_link = False
return
supplier_name = supplier_link[0].parent
proposals = frappe.get_all("Supplier Product Proposal", filters={
"supplier": supplier_name
}, fields=["name", "product_name", "supplier_price", "status"])
context.proposals = proposals
context.add_proposal_link = True`
What I’ve Tried:
- I’ve confirmed that the Python controller’s logic correctly finds the
Supplier
name when I run the query manually. - I’ve moved the Jinja template code from the
Web Page
’sMain Section
to a separatesupplier_dashboard.html
file in thewww
folder. - I have tried using both the
Controller
field and theDynamic Template
checkbox with the pathwww/supplier_dashboard.html
. However, theController
field seems to be missing from myWeb Page
document. - When I use
Dynamic Template
, the page shows the literal pathwww/supplier_dashboard.html
as plain text. - I have run
bench clear-cache
andbench restart
multiple times. - My files are correctly placed in
apps/marketplace_app/marketplace_app/www/
.
It seems the Web Page
document is not correctly running my Python script or rendering the template. Any help would be greatly appreciated. Thank you!