diff --git a/erpnext/accounts/doctype/payment_request/payment_request.py b/erpnext/accounts/doctype/payment_request/payment_request.py index 47cb3fd812f..72f6ba48af2 100644 --- a/erpnext/accounts/doctype/payment_request/payment_request.py +++ b/erpnext/accounts/doctype/payment_request/payment_request.py @@ -25,6 +25,15 @@ from erpnext.accounts.utils import get_account_currency, get_currency_precision from erpnext.erpnext_integrations.stripe_integration import create_stripe_subscription 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(): @@ -492,6 +501,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() diff --git a/erpnext/templates/pages/order.py b/erpnext/templates/pages/order.py index 6219aac6978..38f3f0b2d7b 100644 --- a/erpnext/templates/pages/order.py +++ b/erpnext/templates/pages/order.py @@ -4,7 +4,13 @@ import frappe from frappe import _ +<<<<<<< HEAD from erpnext.e_commerce.doctype.e_commerce_settings.e_commerce_settings import show_attachments +======= +from erpnext.accounts.doctype.payment_request.payment_request import ( + ALLOWED_DOCTYPES_FOR_PAYMENT_REQUEST, +) +>>>>>>> d2e5b2aa1d (fix: only show pay button for specific doctype in portal) def get_context(context): @@ -53,7 +59,15 @@ def get_context(context): ) context.available_loyalty_points = int(loyalty_program_details.get("loyalty_points")) +<<<<<<< HEAD context.show_pay_button = 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 + ) +>>>>>>> d2e5b2aa1d (fix: only show pay button for specific doctype in portal) context.show_make_pi_button = False if context.doc.get("supplier"): # show Make Purchase Invoice button based on permission