From ebc4ae789245a11235a2970613535fc24befc247 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 2 Jan 2015 12:46:49 +0530 Subject: [PATCH] patch fixes --- erpnext/patches.txt | 5 ++-- erpnext/patches/v4_2/party_model.py | 2 +- .../v5_0/recalculate_total_amount_in_jv.py | 28 +++++++++++++------ .../patches/v5_0/remove_shopping_cart_app.py | 6 ++++ .../patches/v5_0/rename_table_fieldnames.py | 6 ++++ 5 files changed, 35 insertions(+), 12 deletions(-) create mode 100644 erpnext/patches/v5_0/remove_shopping_cart_app.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 28c1f2c250..c9001df10b 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -85,7 +85,6 @@ execute:frappe.delete_doc("DocType", "Purchase Request Item") erpnext.patches.v4_2.recalculate_bom_cost erpnext.patches.v4_2.fix_gl_entries_for_stock_transactions erpnext.patches.v4_2.update_requested_and_ordered_qty -erpnext.patches.v4_2.party_model erpnext.patches.v4_4.make_email_accounts execute:frappe.delete_doc("DocType", "Contact Control") erpnext.patches.v4_2.reset_bom_costs @@ -98,6 +97,8 @@ execute:frappe.rename_doc("DocType", "Support Ticket", "Issue", force=True) erpnext.patches.v5_0.set_default_company_in_bom erpnext.patches.v5_0.capacity_planning erpnext.patches.v5_0.rename_table_fieldnames -erpnext.patches.v5_0.recalculate_total_amount_in_jv execute:frappe.db.sql("update `tabJournal Entry` set voucher_type='Journal Entry' where ifnull(voucher_type, '')=''") +erpnext.patches.v4_2.party_model erpnext.patches.v4_1.fix_jv_remarks +erpnext.patches.v5_0.recalculate_total_amount_in_jv +erpnext.patches.v5_0.remove_shopping_cart_app diff --git a/erpnext/patches/v4_2/party_model.py b/erpnext/patches/v4_2/party_model.py index d41ef6231b..8ac4afde3f 100644 --- a/erpnext/patches/v4_2/party_model.py +++ b/erpnext/patches/v4_2/party_model.py @@ -7,8 +7,8 @@ import frappe def execute(): frappe.reload_doc("accounts", "doctype", "account") frappe.reload_doc("setup", "doctype", "company") - frappe.reload_doc("accounts", "doctype", "journal_entry_account") frappe.reload_doc("accounts", "doctype", "gl_entry") + frappe.reload_doc("accounts", "doctype", "journal_entry_account") receivable_payable_accounts = create_receivable_payable_account() if receivable_payable_accounts: set_party_in_jv_and_gl_entry(receivable_payable_accounts) diff --git a/erpnext/patches/v5_0/recalculate_total_amount_in_jv.py b/erpnext/patches/v5_0/recalculate_total_amount_in_jv.py index afb568107e..7e6a4a92d1 100644 --- a/erpnext/patches/v5_0/recalculate_total_amount_in_jv.py +++ b/erpnext/patches/v5_0/recalculate_total_amount_in_jv.py @@ -2,14 +2,24 @@ # License: GNU General Public License v3. See license.txt import frappe +from frappe.utils import money_in_words def execute(): - for d in frappe.db.sql("""select name from `tabJournal Entry` where docstatus < 2 """, as_dict=1): - try: - jv = frappe.get_doc('Journal Entry', d.name) - jv.ignore_validate_update_after_submit = True - jv.set_print_format_fields() - jv.save() - frappe.db.commit() - except: - frappe.db.rollback() \ No newline at end of file + company_currency = dict(frappe.db.sql("select name, default_currency from `tabCompany`")) + bank_or_cash_accounts = frappe.db.sql_list("""select name from `tabAccount` + where account_type in ('Bank', 'Cash') and docstatus < 2""") + + for je in frappe.db.sql_list("""select name from `tabJournal Entry` where docstatus < 2"""): + total_amount = 0 + total_amount_in_words = "" + + je_doc = frappe.get_doc('Journal Entry', je) + for d in je_doc.get("accounts"): + if (d.party_type and d.party) or d.account in bank_or_cash_accounts: + total_amount = d.debit or d.credit + if total_amount: + total_amount_in_words = money_in_words(total_amount, company_currency.get(je_doc.company)) + + if total_amount: + frappe.db.sql("""update `tabJournal Entry` set total_amount=%s, total_amount_in_words=%s + where name = %s""", (total_amount, total_amount_in_words, je)) diff --git a/erpnext/patches/v5_0/remove_shopping_cart_app.py b/erpnext/patches/v5_0/remove_shopping_cart_app.py new file mode 100644 index 0000000000..318f59ef75 --- /dev/null +++ b/erpnext/patches/v5_0/remove_shopping_cart_app.py @@ -0,0 +1,6 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +def execute(): + from frappe.installer import remove_from_installed_apps + remove_from_installed_apps("shopping_cart") diff --git a/erpnext/patches/v5_0/rename_table_fieldnames.py b/erpnext/patches/v5_0/rename_table_fieldnames.py index 53d807fa23..d1e59f2e1d 100644 --- a/erpnext/patches/v5_0/rename_table_fieldnames.py +++ b/erpnext/patches/v5_0/rename_table_fieldnames.py @@ -233,7 +233,13 @@ def execute(): if "tab"+new_dt not in tables: frappe.rename_doc("DocType", old_dt, new_dt, force=True) + # reload new child doctypes frappe.reload_doc("manufacturing", "doctype", "production_order_operation") + frappe.reload_doc("manufacturing", "doctype", "workstation_working_hour") + frappe.reload_doc("stock", "doctype", "item_variant") + frappe.reload_doc("accounts", "doctype", "party_account") + frappe.reload_doc("accounts", "doctype", "fiscal_year_company") + frappe.reload_doc("workflow", "doctype", "workflow") #rename table fieldnames for dn in rename_map: