[hot] [fix] journal entry
diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.js b/erpnext/accounts/doctype/journal_entry/journal_entry.js
index ec632ec..d7e5ee0 100644
--- a/erpnext/accounts/doctype/journal_entry/journal_entry.js
+++ b/erpnext/accounts/doctype/journal_entry/journal_entry.js
@@ -138,6 +138,8 @@
cur_frm.cscript.refresh = function(doc) {
cur_frm.cscript.is_opening(doc)
erpnext.toggle_naming_series();
+ cur_frm.cscript.voucher_type();
+
if(doc.docstatus==1) {
cur_frm.add_custom_button(__('View Ledger'), function() {
frappe.route_options = {
@@ -235,37 +237,37 @@
refresh_field("accounts");
}
- if(in_list(["Bank Entry", "Cash Entry"], doc.voucher_type)) {
- cur_frm.clear_table("accounts");
- return frappe.call({
- type: "GET",
- method: "erpnext.accounts.doctype.journal_entry.journal_entry.get_default_bank_cash_account",
- args: {
- "voucher_type": doc.voucher_type,
- "company": doc.company
- },
- callback: function(r) {
- if(r.message) {
- update_jv_details(doc, [r.message]);
+ if(!(doc.accounts || []).length) {
+ if(in_list(["Bank Entry", "Cash Entry"], doc.voucher_type)) {
+ return frappe.call({
+ type: "GET",
+ method: "erpnext.accounts.doctype.journal_entry.journal_entry.get_default_bank_cash_account",
+ args: {
+ "voucher_type": doc.voucher_type,
+ "company": doc.company
+ },
+ callback: function(r) {
+ if(r.message) {
+ update_jv_details(doc, [r.message]);
+ }
}
- }
- })
- } else if(doc.voucher_type=="Opening Entry") {
- cur_frm.clear_table("accounts");
- return frappe.call({
- type:"GET",
- method: "erpnext.accounts.doctype.journal_entry.journal_entry.get_opening_accounts",
- args: {
- "company": doc.company
- },
- callback: function(r) {
- frappe.model.clear_table(doc, "accounts");
- if(r.message) {
- update_jv_details(doc, r.message);
+ })
+ } else if(doc.voucher_type=="Opening Entry") {
+ return frappe.call({
+ type:"GET",
+ method: "erpnext.accounts.doctype.journal_entry.journal_entry.get_opening_accounts",
+ args: {
+ "company": doc.company
+ },
+ callback: function(r) {
+ frappe.model.clear_table(doc, "accounts");
+ if(r.message) {
+ update_jv_details(doc, r.message);
+ }
+ cur_frm.set_value("is_opening", "Yes")
}
- cur_frm.set_value("is_opening", "Yes")
- }
- })
+ })
+ }
}
}