From 7fbdba02abbf2f327358641dbfa77ae722f9b461 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 25 Mar 2014 13:50:52 +0530 Subject: [PATCH] Fixed Countrywise Chart of Accounts patch --- erpnext/patches.txt | 4 +++- erpnext/patches/4_0/countrywise_coa.py | 4 ++-- erpnext/patches/4_0/import_country_codes.py | 6 +++--- erpnext/setup/install.py | 15 ++++++++------- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 8c20452b85..c1092507fb 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -1,3 +1,5 @@ +execute:import unidecode # new requirement + erpnext.patches.4_0.validate_v3_patch erpnext.patches.4_0.update_user_properties erpnext.patches.4_0.move_warehouse_user_to_restrictions @@ -29,6 +31,6 @@ erpnext.patches.4_0.remove_module_home_pages erpnext.patches.4_0.split_email_settings erpnext.patches.4_0.fix_employee_user_id erpnext.patches.4_0.import_country_codes -execute:patches.4_0.countrywise_coa +erpnext.patches.4_0.countrywise_coa execute:frappe.delete_doc("DocType", "MIS Control") execute:frappe.delete_doc("Page", "Financial Statements") diff --git a/erpnext/patches/4_0/countrywise_coa.py b/erpnext/patches/4_0/countrywise_coa.py index 242585652f..bddb2795fe 100644 --- a/erpnext/patches/4_0/countrywise_coa.py +++ b/erpnext/patches/4_0/countrywise_coa.py @@ -12,12 +12,12 @@ def execute(): where account_type='Bank or Cash' and account_name in ('Cash', 'Cash In Hand')""") ac_types = {"Fixed Asset Account": "Fixed Asset", "Bank or Cash": "Bank"} - for old, new in ac_types.items: + for old, new in ac_types.items(): frappe.db.sql("""update tabAccount set account_type=%s where account_type=%s""", (new, old)) frappe.db.sql("""update `tabAccount` set report_type = - if(is_pl_account=='Yes', 'Profit and Loss', 'Balance Sheet')""") + if(is_pl_account='Yes', 'Profit and Loss', 'Balance Sheet')""") frappe.db.sql("""update `tabAccount` set balance_must_be=debit_or_credit where ifnull(allow_negative_balance, 0) = 0""") \ No newline at end of file diff --git a/erpnext/patches/4_0/import_country_codes.py b/erpnext/patches/4_0/import_country_codes.py index 9a4ddcb28a..4d1177ed5d 100644 --- a/erpnext/patches/4_0/import_country_codes.py +++ b/erpnext/patches/4_0/import_country_codes.py @@ -3,11 +3,11 @@ from __future__ import unicode_literals import frappe +from frappe.country_info import get_all +from erpnext.setup.install import import_country_and_currency def execute(): frappe.reload_doc("setup", "doctype", "country") - - from frappe.country_info import get_all - + import_country_and_currency() for name, country in get_all().iteritems(): frappe.set_value("Country", name, "code", country.get("code")) \ No newline at end of file diff --git a/erpnext/setup/install.py b/erpnext/setup/install.py index a7707a179f..ae81fbd3e4 100644 --- a/erpnext/setup/install.py +++ b/erpnext/setup/install.py @@ -23,13 +23,14 @@ def import_country_and_currency(): for name in data: country = frappe._dict(data[name]) - frappe.doc({ - "doctype": "Country", - "country_name": name, - "code": country.code, - "date_format": country.date_format or "dd-mm-yyyy", - "time_zones": "\n".join(country.timezones or []) - }).insert() + if not frappe.db.exists("Country", name): + frappe.doc({ + "doctype": "Country", + "country_name": name, + "code": country.code, + "date_format": country.date_format or "dd-mm-yyyy", + "time_zones": "\n".join(country.timezones or []) + }).insert() if country.currency and not frappe.db.exists("Currency", country.currency): frappe.doc({