mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-16 03:29:16 +00:00
fix: only show pay button for specific doctype in portal
(cherry picked from commit fc2cac62c1)
# Conflicts:
# erpnext/accounts/doctype/payment_request/payment_request.py
# erpnext/templates/pages/order.py
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.
|
||||||
@@ -524,6 +534,15 @@ def make_payment_request(**args):
|
|||||||
"""Make payment request"""
|
"""Make payment request"""
|
||||||
|
|
||||||
args = frappe._dict(args)
|
args = frappe._dict(args)
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
ref_doc = args.ref_doc or frappe.get_doc(args.dt, args.dn)
|
||||||
|
|
||||||
|
if ref_doc.doctype not in ALLOWED_DOCTYPES_FOR_PAYMENT_REQUEST:
|
||||||
|
frappe.throw(
|
||||||
|
_("Payment Requests cannot be created against: {0}").format(frappe.bold(ref_doc.doctype))
|
||||||
|
)
|
||||||
|
>>>>>>> fc2cac62c1 (fix: only show pay button for specific doctype in portal)
|
||||||
|
|
||||||
ref_doc = frappe.get_doc(args.dt, args.dn)
|
ref_doc = frappe.get_doc(args.dt, args.dn)
|
||||||
gateway_account = get_gateway_details(args) or frappe._dict()
|
gateway_account = get_gateway_details(args) or frappe._dict()
|
||||||
|
|||||||
@@ -4,6 +4,14 @@
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
from erpnext.accounts.doctype.payment_request.payment_request import (
|
||||||
|
ALLOWED_DOCTYPES_FOR_PAYMENT_REQUEST,
|
||||||
|
get_amount,
|
||||||
|
)
|
||||||
|
|
||||||
|
>>>>>>> fc2cac62c1 (fix: only show pay button for specific doctype in portal)
|
||||||
|
|
||||||
def get_context(context):
|
def get_context(context):
|
||||||
context.no_cache = 1
|
context.no_cache = 1
|
||||||
@@ -61,3 +69,22 @@ def get_attachments(dt, dn):
|
|||||||
fields=["name", "file_name", "file_url", "is_private"],
|
fields=["name", "file_name", "file_url", "is_private"],
|
||||||
filters={"attached_to_name": dn, "attached_to_doctype": dt, "is_private": 0},
|
filters={"attached_to_name": dn, "attached_to_doctype": dt, "is_private": 0},
|
||||||
)
|
)
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
|
||||||
|
|
||||||
|
def get_payment_details(doc):
|
||||||
|
show_pay_button, amount = (
|
||||||
|
(
|
||||||
|
"payments" in frappe.get_installed_apps()
|
||||||
|
and frappe.db.get_single_value("Buying Settings", "show_pay_button")
|
||||||
|
and doc.doctype in ALLOWED_DOCTYPES_FOR_PAYMENT_REQUEST
|
||||||
|
),
|
||||||
|
0,
|
||||||
|
)
|
||||||
|
if not show_pay_button:
|
||||||
|
return show_pay_button, amount
|
||||||
|
|
||||||
|
amount = get_amount(doc)
|
||||||
|
return bool(amount), amount
|
||||||
|
>>>>>>> fc2cac62c1 (fix: only show pay button for specific doctype in portal)
|
||||||
|
|||||||
Reference in New Issue
Block a user