From 5445c460b7abecb37c4b042b666c8bf54ee8205d Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 2 Apr 2015 17:42:02 +0530 Subject: [PATCH] [fix] [patch] party model patch --- erpnext/patches.txt | 1 + erpnext/patches/v5_0/party_model_patch_fix.py | 18 ++++++++++++++++++ .../patches/v5_0/rename_table_fieldnames.py | 3 --- 3 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 erpnext/patches/v5_0/party_model_patch_fix.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 14ec93f833..78c75fef12 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -102,6 +102,7 @@ execute:frappe.reload_doc('crm', 'doctype', 'opportunity') erpnext.patches.v5_0.rename_table_fieldnames execute:frappe.db.sql("update `tabJournal Entry` set voucher_type='Journal Entry' where ifnull(voucher_type, '')=''") erpnext.patches.v4_2.party_model +erpnext.patches.v5_0.party_model_patch_fix erpnext.patches.v4_1.fix_jv_remarks erpnext.patches.v4_2.update_landed_cost_voucher erpnext.patches.v4_2.set_item_has_batch diff --git a/erpnext/patches/v5_0/party_model_patch_fix.py b/erpnext/patches/v5_0/party_model_patch_fix.py new file mode 100644 index 0000000000..d9b6709792 --- /dev/null +++ b/erpnext/patches/v5_0/party_model_patch_fix.py @@ -0,0 +1,18 @@ +from __future__ import unicode_literals +import frappe + +def execute(): + for company in frappe.get_all("Company", + ["name", "default_receivable_account", "default_payable_account"]): + + if company.default_receivable_account: + frappe.db.sql("""update `tabSales Invoice` invoice set `debit_to`=%(account)s + where company=%(company)s + and not exists (select name from `tabAccount` account where account.name=invoice.debit_to)""", + {"company": company.name, "account": company.default_receivable_account}) + + if company.default_payable_account: + frappe.db.sql("""update `tabPurchase Invoice` invoice set `credit_to`=%(account)s + where company=%(company)s + and not exists (select name from `tabAccount` account where account.name=invoice.credit_to)""", + {"company": company.name, "account": company.default_payable_account}) diff --git a/erpnext/patches/v5_0/rename_table_fieldnames.py b/erpnext/patches/v5_0/rename_table_fieldnames.py index ca92c28790..cbe93c2f77 100644 --- a/erpnext/patches/v5_0/rename_table_fieldnames.py +++ b/erpnext/patches/v5_0/rename_table_fieldnames.py @@ -157,9 +157,6 @@ rename_map = { ["pp_so_details", "sales_orders"], ["pp_details", "items"] ], - "Project": [ - ["project_milestones", "milestones"] - ], "Quality Inspection": [ ["qa_specification_details", "readings"] ],