diff --git a/erpnext/loan_management/doctype/loan_application/loan_application.js b/erpnext/loan_management/doctype/loan_application/loan_application.js index aba5f4260c4..6cf47bf85c7 100644 --- a/erpnext/loan_management/doctype/loan_application/loan_application.js +++ b/erpnext/loan_management/doctype/loan_application/loan_application.js @@ -31,7 +31,7 @@ frappe.ui.form.on('Loan Application', { add_toolbar_buttons: function(frm) { if (frm.doc.status == "Approved") { - if (frm.doc.is_secured) { + if (frm.doc.is_secured_loan) { frappe.db.get_value("Loan Security Pledge", {"loan_application": frm.doc.name, "docstatus": 1}, "name", (r) => { if (!r) { frm.add_custom_button(__('Loan Security Pledge'), function() { diff --git a/erpnext/loan_management/doctype/loan_security_pledge/loan_security_pledge.py b/erpnext/loan_management/doctype/loan_security_pledge/loan_security_pledge.py index b405ccae55d..eb6135868d0 100644 --- a/erpnext/loan_management/doctype/loan_security_pledge/loan_security_pledge.py +++ b/erpnext/loan_management/doctype/loan_security_pledge/loan_security_pledge.py @@ -30,7 +30,8 @@ class LoanSecurityPledge(Document): if not pledge.qty and not pledge.amount: frappe.throw(_("Qty or Amount is mandatroy for loan security")) - pledge.loan_security_price = get_loan_security_price(pledge.loan_security) + if not (self.loan_application and pledge.loan_security_price): + pledge.loan_security_price = get_loan_security_price(pledge.loan_security) if not pledge.qty: pledge.qty = cint(pledge.amount/pledge.loan_security_price) diff --git a/erpnext/loan_management/doctype/loan_security_price/loan_security_price.py b/erpnext/loan_management/doctype/loan_security_price/loan_security_price.py index 2855b52610a..32d81afed5d 100644 --- a/erpnext/loan_management/doctype/loan_security_price/loan_security_price.py +++ b/erpnext/loan_management/doctype/loan_security_price/loan_security_price.py @@ -37,7 +37,7 @@ def get_loan_security_price(loan_security, valid_time=None): }, 'loan_security_price') if not loan_security_price: - frappe.throw(_("No valid Loan Security Price found for {0}").format(frappe.bold(loan_security))) + frappe.throw(_("No valid Loan Security Price found for {0}").format(frappe.bold(loan_security))) else: return loan_security_price