fix: hide payment and payment request buttons based on permissions in invoices and orders (backport #53920) (#54735)

Co-authored-by: ravibharathi656 <ravibharathi656@gmail.com>
Co-authored-by: Sakthivel Murugan S <129778327+ssakthivelmurugan@users.noreply.github.com>
Co-authored-by: diptanilsaha <diptanil@frappe.io>
fix: hide payment and payment request buttons based on permissions in invoices and orders (#53920)
This commit is contained in:
mergify[bot]
2026-05-05 12:25:18 +05:30
committed by GitHub
parent 1a406e90c1
commit 9c9ecc77f8
4 changed files with 36 additions and 17 deletions

View File

@@ -115,7 +115,12 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying.
} }
} }
if (doc.docstatus == 1 && doc.outstanding_amount != 0 && !doc.on_hold) { if (
doc.docstatus == 1 &&
doc.outstanding_amount != 0 &&
!doc.on_hold &&
frappe.model.can_create("Payment Entry")
) {
this.frm.add_custom_button(__("Payment"), () => this.make_payment_entry(), __("Create")); this.frm.add_custom_button(__("Payment"), () => this.make_payment_entry(), __("Create"));
cur_frm.page.set_inner_btn_group_as_primary(__("Create")); cur_frm.page.set_inner_btn_group_as_primary(__("Create"));
} }
@@ -126,7 +131,13 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying.
} }
} }
if (doc.docstatus == 1 && doc.outstanding_amount > 0 && !cint(doc.is_return) && !doc.on_hold) { if (
doc.docstatus == 1 &&
doc.outstanding_amount > 0 &&
!cint(doc.is_return) &&
!doc.on_hold &&
frappe.boot.user.in_create.includes("Payment Request")
) {
this.frm.add_custom_button( this.frm.add_custom_button(
__("Payment Request"), __("Payment Request"),
function () { function () {

View File

@@ -94,7 +94,7 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends (
erpnext.accounts.ledger_preview.show_stock_ledger_preview(this.frm); erpnext.accounts.ledger_preview.show_stock_ledger_preview(this.frm);
} }
if (doc.docstatus == 1 && doc.outstanding_amount != 0) { if (doc.docstatus == 1 && doc.outstanding_amount != 0 && frappe.model.can_create("Payment Entry")) {
this.frm.add_custom_button(__("Payment"), () => this.make_payment_entry(), __("Create")); this.frm.add_custom_button(__("Payment"), () => this.make_payment_entry(), __("Create"));
this.frm.page.set_inner_btn_group_as_primary(__("Create")); this.frm.page.set_inner_btn_group_as_primary(__("Create"));
} }
@@ -136,13 +136,15 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends (
} }
if (doc.outstanding_amount > 0) { if (doc.outstanding_amount > 0) {
cur_frm.add_custom_button( if (frappe.boot.user.in_create.includes("Payment Request")) {
this.frm.add_custom_button(
__("Payment Request"), __("Payment Request"),
function () { function () {
me.make_payment_request(); me.make_payment_request_with_schedule();
}, },
__("Create") __("Create")
); );
}
this.frm.add_custom_button( this.frm.add_custom_button(
__("Invoice Discounting"), __("Invoice Discounting"),
this.make_invoice_discounting.bind(this), this.make_invoice_discounting.bind(this),

View File

@@ -440,7 +440,11 @@ erpnext.buying.PurchaseOrderController = class PurchaseOrderController extends (
__("Create") __("Create")
); );
if (flt(doc.per_billed) < 100 && doc.status != "Delivered") { if (
frappe.model.can_create("Payment Entry") &&
flt(doc.per_billed) < 100 &&
doc.status != "Delivered"
) {
this.frm.add_custom_button( this.frm.add_custom_button(
__("Payment"), __("Payment"),
() => this.make_payment_entry(), () => this.make_payment_entry(),
@@ -448,7 +452,7 @@ erpnext.buying.PurchaseOrderController = class PurchaseOrderController extends (
); );
} }
if (flt(doc.per_billed) < 100) { if (flt(doc.per_billed) < 100 && frappe.boot.user.in_create.includes("Payment Request")) {
this.frm.add_custom_button( this.frm.add_custom_button(
__("Payment Request"), __("Payment Request"),
function () { function () {

View File

@@ -773,11 +773,13 @@ erpnext.selling.SalesOrderController = class SalesOrderController extends erpnex
} }
// payment request // payment request
if (flt(doc.per_billed) < 100 + frappe.boot.sysdefaults.over_billing_allowance) { if (flt(doc.per_billed) < 100 + frappe.boot.sysdefaults.over_billing_allowance) {
if (frappe.boot.user.in_create.includes("Payment Request")) {
this.frm.add_custom_button( this.frm.add_custom_button(
__("Payment Request"), __("Payment Request"),
() => this.make_payment_request(), () => this.make_payment_request_with_schedule(),
__("Create") __("Create")
); );
}
if (frappe.model.can_create("Payment Entry")) { if (frappe.model.can_create("Payment Entry")) {
this.frm.add_custom_button( this.frm.add_custom_button(