From c5f257da00e1c490571e303f2eb790773cbabd9c Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 21 Mar 2022 14:22:10 +0530 Subject: [PATCH] fix: While creating Payment Request from other forms, open a new Payment Request form without saving (#30228) --- erpnext/accounts/doctype/payment_request/payment_request.py | 2 +- .../accounts/doctype/payment_request/test_payment_request.py | 1 + erpnext/accounts/doctype/pos_invoice/pos_invoice.py | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/payment_request/payment_request.py b/erpnext/accounts/doctype/payment_request/payment_request.py index 5cf534faba1..f77b060ee29 100644 --- a/erpnext/accounts/doctype/payment_request/payment_request.py +++ b/erpnext/accounts/doctype/payment_request/payment_request.py @@ -376,8 +376,8 @@ def make_payment_request(**args): if args.order_type == "Shopping Cart" or args.mute_email: pr.flags.mute_email = True - pr.insert(ignore_permissions=True) if args.submit_doc: + pr.insert(ignore_permissions=True) pr.submit() if args.order_type == "Shopping Cart": diff --git a/erpnext/accounts/doctype/payment_request/test_payment_request.py b/erpnext/accounts/doctype/payment_request/test_payment_request.py index f679ccfe4ff..cc70a96e742 100644 --- a/erpnext/accounts/doctype/payment_request/test_payment_request.py +++ b/erpnext/accounts/doctype/payment_request/test_payment_request.py @@ -128,6 +128,7 @@ class TestPaymentRequest(unittest.TestCase): pr1 = make_payment_request(dt="Sales Order", dn=so.name, recipient_id="nabin@erpnext.com", return_doc=1) pr1.grand_total = 200 + pr1.insert() pr1.submit() # Make a 2nd Payment Request diff --git a/erpnext/accounts/doctype/pos_invoice/pos_invoice.py b/erpnext/accounts/doctype/pos_invoice/pos_invoice.py index 466b2833fe1..431036abc18 100644 --- a/erpnext/accounts/doctype/pos_invoice/pos_invoice.py +++ b/erpnext/accounts/doctype/pos_invoice/pos_invoice.py @@ -456,6 +456,7 @@ class POSInvoice(SalesInvoice): pay_req = self.get_existing_payment_request(pay) if not pay_req: pay_req = self.get_new_payment_request(pay) + pay_req.insert() pay_req.submit() else: pay_req.request_phone_payment()