[fix] [patch] party model patch
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 14ec93f..78c75fe 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -102,6 +102,7 @@
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 0000000..d9b6709
--- /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 ca92c28..cbe93c2 100644
--- a/erpnext/patches/v5_0/rename_table_fieldnames.py
+++ b/erpnext/patches/v5_0/rename_table_fieldnames.py
@@ -157,9 +157,6 @@
["pp_so_details", "sales_orders"],
["pp_details", "items"]
],
- "Project": [
- ["project_milestones", "milestones"]
- ],
"Quality Inspection": [
["qa_specification_details", "readings"]
],