fix: only show pay button for specific doctype in portal
This commit is contained in:
@@ -20,6 +20,15 @@ from erpnext.accounts.party import get_party_account, get_party_bank_account
|
||||
from erpnext.accounts.utils import get_account_currency, get_currency_precision
|
||||
from erpnext.utilities import payment_app_import_guard
|
||||
|
||||
ALLOWED_DOCTYPES_FOR_PAYMENT_REQUEST = [
|
||||
"Sales Order",
|
||||
"Purchase Order",
|
||||
"Sales Invoice",
|
||||
"Purchase Invoice",
|
||||
"POS Invoice",
|
||||
"Fees",
|
||||
]
|
||||
|
||||
|
||||
def _get_payment_gateway_controller(*args, **kwargs):
|
||||
with payment_app_import_guard():
|
||||
@@ -525,6 +534,9 @@ def make_payment_request(**args):
|
||||
|
||||
args = frappe._dict(args)
|
||||
|
||||
if args.dt not in ALLOWED_DOCTYPES_FOR_PAYMENT_REQUEST:
|
||||
frappe.throw(_("Payment Requests cannot be created against: {0}").format(frappe.bold(args.dt)))
|
||||
|
||||
ref_doc = frappe.get_doc(args.dt, args.dn)
|
||||
gateway_account = get_gateway_details(args) or frappe._dict()
|
||||
|
||||
|
||||
@@ -4,6 +4,10 @@
|
||||
import frappe
|
||||
from frappe import _
|
||||
|
||||
from erpnext.accounts.doctype.payment_request.payment_request import (
|
||||
ALLOWED_DOCTYPES_FOR_PAYMENT_REQUEST,
|
||||
)
|
||||
|
||||
|
||||
def get_context(context):
|
||||
context.no_cache = 1
|
||||
@@ -46,8 +50,10 @@ def get_context(context):
|
||||
)
|
||||
context.available_loyalty_points = int(loyalty_program_details.get("loyalty_points"))
|
||||
|
||||
context.show_pay_button = "payments" in frappe.get_installed_apps() and frappe.db.get_single_value(
|
||||
"Buying Settings", "show_pay_button"
|
||||
context.show_pay_button = (
|
||||
"payments" in frappe.get_installed_apps()
|
||||
and frappe.db.get_single_value("Buying Settings", "show_pay_button")
|
||||
and context.doc.doctype in ALLOWED_DOCTYPES_FOR_PAYMENT_REQUEST
|
||||
)
|
||||
context.show_make_pi_button = False
|
||||
if context.doc.get("supplier"):
|
||||
|
||||
Reference in New Issue
Block a user