fix: only show pay button for specific doctype in portal

(cherry picked from commit d2e5b2aa1d)

# Conflicts:
#	erpnext/templates/pages/order.py
This commit is contained in:
ljain112
2024-10-22 19:49:37 +05:30
committed by Mergify
parent 1a4a329c1d
commit 5740683ce9
2 changed files with 26 additions and 0 deletions

View File

@@ -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()

View File

@@ -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