fix: show `Make Purchase Invoice` button based on permission
diff --git a/erpnext/templates/pages/order.html b/erpnext/templates/pages/order.html
index a10870d..ec1d497 100644
--- a/erpnext/templates/pages/order.html
+++ b/erpnext/templates/pages/order.html
@@ -18,7 +18,7 @@
<b class="caret"></b>
</button>
<ul class="dropdown-menu dropdown-menu-right" role="menu">
- {% if doc.doctype == 'Purchase Order' %}
+ {% if doc.doctype == 'Purchase Order' and show_make_pi_button %}
<a class="dropdown-item" href="/api/method/erpnext.buying.doctype.purchase_order.purchase_order.make_purchase_invoice_from_portal?purchase_order_name={{ doc.name }}" data-action="make_purchase_invoice">{{ _("Make Purchase Invoice") }}</a>
{% endif %}
<a class="dropdown-item" href='/printview?doctype={{ doc.doctype}}&name={{ doc.name }}&format={{ print_format }}'
diff --git a/erpnext/templates/pages/order.py b/erpnext/templates/pages/order.py
index 3e6d57a..e1e12bd 100644
--- a/erpnext/templates/pages/order.py
+++ b/erpnext/templates/pages/order.py
@@ -52,6 +52,9 @@
)
context.available_loyalty_points = int(loyalty_program_details.get("loyalty_points"))
+ # show Make Purchase Invoice button based on permission
+ context.show_make_pi_button = frappe.has_permission("Purchase Invoice", "create")
+
def get_attachments(dt, dn):
return frappe.get_all(