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

Co-authored-by: Sakthivel Murugan S <129778327+ssakthivelmurugan@users.noreply.github.com>
Co-authored-by: ravibharathi656 <ravibharathi656@gmail.com>
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:17:57 +05:30
committed by GitHub
parent 2cd4c1a052
commit e60490dceb
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"));
this.frm.page.set_inner_btn_group_as_primary(__("Create")); this.frm.page.set_inner_btn_group_as_primary(__("Create"));
} }
@@ -130,7 +135,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"));
} }
@@ -135,6 +135,7 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends (
} }
if (doc.outstanding_amount > 0) { if (doc.outstanding_amount > 0) {
if (frappe.boot.user.in_create.includes("Payment Request")) {
this.frm.add_custom_button( this.frm.add_custom_button(
__("Payment Request"), __("Payment Request"),
function () { function () {
@@ -142,6 +143,7 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends (
}, },
__("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

@@ -416,7 +416,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(),
@@ -424,7 +428,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

@@ -1162,11 +1162,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_with_schedule(), () => 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(