From a2436e4b6e8a677bb759b57c72f7df44560653bf Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 4 Jul 2025 20:10:27 +0200 Subject: [PATCH] fix(Quotation): hide buttons if user cannot use them (backport #48115) (#48405) Co-authored-by: Raffael Meyer <14891507+barredterra@users.noreply.github.com> fix(Quotation): hide buttons if user cannot use them (#48115) --- erpnext/selling/doctype/quotation/quotation.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js index 685b27ab3ef..da8476d6b1f 100644 --- a/erpnext/selling/doctype/quotation/quotation.js +++ b/erpnext/selling/doctype/quotation/quotation.js @@ -117,14 +117,15 @@ erpnext.selling.QuotationController = class QuotationController extends erpnext. if (doc.docstatus == 1 && !["Lost", "Ordered"].includes(doc.status)) { if ( - frappe.boot.sysdefaults.allow_sales_order_creation_for_expired_quotation || - !doc.valid_till || - frappe.datetime.get_diff(doc.valid_till, frappe.datetime.get_today()) >= 0 + frappe.model.can_create("Sales Order") && + (frappe.boot.sysdefaults.allow_sales_order_creation_for_expired_quotation || + !doc.valid_till || + frappe.datetime.get_diff(doc.valid_till, frappe.datetime.get_today()) >= 0) ) { this.frm.add_custom_button(__("Sales Order"), () => this.make_sales_order(), __("Create")); } - if (doc.status !== "Ordered") { + if (doc.status !== "Ordered" && this.frm.has_perm("write")) { this.frm.add_custom_button(__("Set as Lost"), () => { this.frm.trigger("set_as_lost_dialog"); }); @@ -133,7 +134,7 @@ erpnext.selling.QuotationController = class QuotationController extends erpnext. cur_frm.page.set_inner_btn_group_as_primary(__("Create")); } - if (this.frm.doc.docstatus === 0) { + if (this.frm.doc.docstatus === 0 && frappe.model.can_read("Opportunity")) { this.frm.add_custom_button( __("Opportunity"), function () {