From bdcfab3a0fcd86c03250a6c5328191ca5cb2a226 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Wed, 25 Mar 2020 21:32:10 +0530 Subject: [PATCH] fix: Update patch and bank form cleanup --- erpnext/accounts/doctype/bank/bank.js | 2 ++ erpnext/accounts/doctype/bank/bank.json | 27 +++---------------- .../doctype/bank_account/bank_account.json | 2 +- .../move_bank_account_swift_number_to_bank.py | 16 ++++------- 4 files changed, 12 insertions(+), 35 deletions(-) diff --git a/erpnext/accounts/doctype/bank/bank.js b/erpnext/accounts/doctype/bank/bank.js index e21c77e9ca..de9498e075 100644 --- a/erpnext/accounts/doctype/bank/bank.js +++ b/erpnext/accounts/doctype/bank/bank.js @@ -13,9 +13,11 @@ frappe.ui.form.on('Bank', { frm.toggle_display(['address_html','contact_html'], !frm.doc.__islocal); if (frm.doc.__islocal) { + frm.set_df_property('address_and_contact', 'hidden', 1); frappe.contacts.clear_address_and_contact(frm); } else { + frm.set_df_property('address_and_contact', 'hidden', 0); frappe.contacts.render_address_and_contact(frm); } }, diff --git a/erpnext/accounts/doctype/bank/bank.json b/erpnext/accounts/doctype/bank/bank.json index fca171d392..99978e657d 100644 --- a/erpnext/accounts/doctype/bank/bank.json +++ b/erpnext/accounts/doctype/bank/bank.json @@ -9,14 +9,14 @@ "editable_grid": 1, "engine": "InnoDB", "field_order": [ - "bank_name", "bank_details_section", + "bank_name", "swift_number", "column_break_1", "branch_code", + "website", "address_and_contact", "address_html", - "website", "column_break_13", "contact_html", "data_import_configuration_section", @@ -44,7 +44,6 @@ "in_list_view": 1, "in_standard_filter": 1, "label": "SWIFT number", - "reqd": 0, "unique": 1 }, { @@ -59,7 +58,6 @@ "in_list_view": 1, "in_standard_filter": 1, "label": "Branch Code", - "reqd": 0, "unique": 1 }, { @@ -112,40 +110,23 @@ "read_only": 1 } ], - "has_web_view": 0, - "hide_heading": 0, - "hide_toolbar": 0, - "idx": 0, - "image_view": 0, - "in_create": 0, - "is_submittable": 0, - "issingle": 0, - "istable": 0, - "max_attachments": 0, - "modified": "2018-11-27 16:12:13.938776", + "links": [], + "modified": "2020-03-25 21:22:33.496264", "modified_by": "Administrator", "module": "Accounts", "name": "Bank", - "name_case": "", "owner": "Administrator", "permissions": [ { - "amend": 0, - "cancel": 0, "create": 1, "delete": 1, "email": 1, "export": 1, - "if_owner": 0, - "import": 0, - "permlevel": 0, "print": 1, "read": 1, "report": 1, "role": "System Manager", - "set_user_permissions": 0, "share": 1, - "submit": 0, "write": 1 } ], diff --git a/erpnext/accounts/doctype/bank_account/bank_account.json b/erpnext/accounts/doctype/bank_account/bank_account.json index ade379b11d..aa9c434db0 100644 --- a/erpnext/accounts/doctype/bank_account/bank_account.json +++ b/erpnext/accounts/doctype/bank_account/bank_account.json @@ -200,7 +200,7 @@ } ], "links": [], - "modified": "2020-01-29 20:42:26.458316", + "modified": "2020-01-30 20:42:26.458316", "modified_by": "Administrator", "module": "Accounts", "name": "Bank Account", diff --git a/erpnext/patches/v12_0/move_bank_account_swift_number_to_bank.py b/erpnext/patches/v12_0/move_bank_account_swift_number_to_bank.py index 2675b98480..4aad1420e3 100644 --- a/erpnext/patches/v12_0/move_bank_account_swift_number_to_bank.py +++ b/erpnext/patches/v12_0/move_bank_account_swift_number_to_bank.py @@ -4,17 +4,11 @@ import frappe def execute(): frappe.reload_doc('accounts', 'doctype', 'bank', force=1) - banks = frappe.get_all('Bank', 'name') - for bank in banks: - bank_accounts = frappe.get_all('Bank Account', filters={'bank': bank.name}, fields=['swift_number', 'branch_code']) - bank_account = '' - if len(bank_accounts): - bank_account = bank_accounts[0] - if bank_account and bank_account.swift_number: - bank.swift_number = bank_account.swift_number - if bank_account and bank_account.branch_code: - bank.branch_code = bank_account.branch_code - bank.save() + frappe.db.sql(""" + UPDATE `tabBank` b, `tabBank Account` ba + SET b.swift_number = ba.swift_number, b.branch_code = ba.branch_code + WHERE b.name = ba.bank + """) frappe.reload_doc('accounts', 'doctype', 'bank_account') frappe.reload_doc('accounts', 'doctype', 'payment_request') \ No newline at end of file