mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-23 23:19:20 +00:00
fix: only show pay button for specific doctype in portal
This commit is contained in:
@@ -28,6 +28,16 @@ def _get_payment_gateway_controller(*args, **kwargs):
|
|||||||
return get_payment_gateway_controller(*args, **kwargs)
|
return get_payment_gateway_controller(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
ALLOWED_DOCTYPES_FOR_PAYMENT_REQUEST = [
|
||||||
|
"Sales Order",
|
||||||
|
"Purchase Order",
|
||||||
|
"Sales Invoice",
|
||||||
|
"Purchase Invoice",
|
||||||
|
"POS Invoice",
|
||||||
|
"Fees",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class PaymentRequest(Document):
|
class PaymentRequest(Document):
|
||||||
# begin: auto-generated types
|
# begin: auto-generated types
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
# This code is auto-generated. Do not modify anything in this block.
|
||||||
@@ -525,14 +535,7 @@ def make_payment_request(**args):
|
|||||||
args = frappe._dict(args)
|
args = frappe._dict(args)
|
||||||
ref_doc = args.ref_doc or frappe.get_doc(args.dt, args.dn)
|
ref_doc = args.ref_doc or frappe.get_doc(args.dt, args.dn)
|
||||||
|
|
||||||
if ref_doc.doctype not in [
|
if ref_doc.doctype not in ALLOWED_DOCTYPES_FOR_PAYMENT_REQUEST:
|
||||||
"Sales Order",
|
|
||||||
"Purchase Order",
|
|
||||||
"Sales Invoice",
|
|
||||||
"Purchase Invoice",
|
|
||||||
"POS Invoice",
|
|
||||||
"Fees",
|
|
||||||
]:
|
|
||||||
frappe.throw(
|
frappe.throw(
|
||||||
_("Payment Requests cannot be created against: {0}").format(frappe.bold(ref_doc.doctype))
|
_("Payment Requests cannot be created against: {0}").format(frappe.bold(ref_doc.doctype))
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -4,7 +4,10 @@
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
|
|
||||||
from erpnext.accounts.doctype.payment_request.payment_request import get_amount
|
from erpnext.accounts.doctype.payment_request.payment_request import (
|
||||||
|
ALLOWED_DOCTYPES_FOR_PAYMENT_REQUEST,
|
||||||
|
get_amount,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_context(context):
|
def get_context(context):
|
||||||
@@ -68,10 +71,12 @@ def get_payment_details(doc):
|
|||||||
(
|
(
|
||||||
"payments" in frappe.get_installed_apps()
|
"payments" in frappe.get_installed_apps()
|
||||||
and frappe.db.get_single_value("Buying Settings", "show_pay_button")
|
and frappe.db.get_single_value("Buying Settings", "show_pay_button")
|
||||||
|
and doc.doctype in ALLOWED_DOCTYPES_FOR_PAYMENT_REQUEST
|
||||||
),
|
),
|
||||||
0,
|
0,
|
||||||
)
|
)
|
||||||
if not show_pay_button:
|
if not show_pay_button:
|
||||||
return show_pay_button, amount
|
return show_pay_button, amount
|
||||||
|
|
||||||
amount = get_amount(doc)
|
amount = get_amount(doc)
|
||||||
return bool(amount), amount
|
return bool(amount), amount
|
||||||
|
|||||||
Reference in New Issue
Block a user