trigger payment_terms_template only when needed (#12124)

diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js
index f1d274d..1814061 100644
--- a/erpnext/public/js/controllers/transaction.js
+++ b/erpnext/public/js/controllers/transaction.js
@@ -105,7 +105,12 @@
 			});
 		}
 
-		if(this.frm.fields_dict["payment_terms_template"]){
+		if(
+			this.frm.fields_dict["payment_terms_template"]
+			&& this.frm.fields_dict["payment_schedule"]
+			&& this.frm.doc.payment_terms_template
+			&& !this.frm.doc.payment_schedule.length
+		){
 			this.frm.trigger("payment_terms_template");
 		}