From 4a069a1e7f2f9e1a6f8bf50463a4cf2fe6931039 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 6 Jun 2014 16:28:03 +0530 Subject: [PATCH 1/2] Changed case in modules.txt --- erpnext/modules.txt | 24 +++++++++---------- erpnext/patches.txt | 1 + .../patches/v4_0/fix_case_of_hr_module_def.py | 11 +++++++++ 3 files changed, 24 insertions(+), 12 deletions(-) create mode 100644 erpnext/patches/v4_0/fix_case_of_hr_module_def.py diff --git a/erpnext/modules.txt b/erpnext/modules.txt index 92614d87e57..32547e957f9 100644 --- a/erpnext/modules.txt +++ b/erpnext/modules.txt @@ -1,12 +1,12 @@ -accounts -buying -home -hr -manufacturing -projects -selling -setup -stock -support -utilities -contacts +Accounts +Buying +Home +HR +Manufacturing +Projects +Selling +Setup +Stock +Support +Utilities +Contacts diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 1ff3136bb79..938beeb0d7c 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -47,6 +47,7 @@ erpnext.patches.v4_0.update_account_root_type execute:frappe.delete_doc("Report", "Purchase In Transit") erpnext.patches.v4_0.new_address_template execute:frappe.delete_doc("DocType", "SMS Control") +erpnext.patches.v4_0.fix_case_of_hr_module_def # WATCHOUT: This patch reload's documents erpnext.patches.v4_0.reset_permissions_for_masters diff --git a/erpnext/patches/v4_0/fix_case_of_hr_module_def.py b/erpnext/patches/v4_0/fix_case_of_hr_module_def.py new file mode 100644 index 00000000000..21edb5861a8 --- /dev/null +++ b/erpnext/patches/v4_0/fix_case_of_hr_module_def.py @@ -0,0 +1,11 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# MIT License. See license.txt + +from __future__ import unicode_literals +import frappe + +def execute(): + hr = frappe.db.get_value("Module Def", "HR") + if hr == "Hr": + frappe.rename_doc("Module Def", "Hr", "HR") + frappe.db.set_value("Module Def", "HR", "module_name", "HR") From fc601659f578afa2d4e24cb1d24f8d1fe6498f1a Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 6 Jun 2014 17:07:50 +0530 Subject: [PATCH 2/2] Fixed Address Template --- erpnext/patches.txt | 1 + erpnext/patches/v4_0/fix_address_template.py | 12 +++ .../patches/v4_0/fix_case_of_hr_module_def.py | 1 - erpnext/patches/v4_0/new_address_template.py | 8 +- .../address_template/address_template.json | 86 +++++++++---------- 5 files changed, 59 insertions(+), 49 deletions(-) create mode 100644 erpnext/patches/v4_0/fix_address_template.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 938beeb0d7c..13d853845a3 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -48,6 +48,7 @@ execute:frappe.delete_doc("Report", "Purchase In Transit") erpnext.patches.v4_0.new_address_template execute:frappe.delete_doc("DocType", "SMS Control") erpnext.patches.v4_0.fix_case_of_hr_module_def +erpnext.patches.v4_0.fix_address_template # WATCHOUT: This patch reload's documents erpnext.patches.v4_0.reset_permissions_for_masters diff --git a/erpnext/patches/v4_0/fix_address_template.py b/erpnext/patches/v4_0/fix_address_template.py new file mode 100644 index 00000000000..5aed489775e --- /dev/null +++ b/erpnext/patches/v4_0/fix_address_template.py @@ -0,0 +1,12 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors + +from __future__ import unicode_literals +import frappe + +def execute(): + missing_line = """{{ address_line1 }}
""" + for name, template in frappe.db.sql("select name, template from `tabAddress Template`"): + if missing_line not in template: + d = frappe.get_doc("Address Template", name) + d.template = missing_line + d.template + d.save() diff --git a/erpnext/patches/v4_0/fix_case_of_hr_module_def.py b/erpnext/patches/v4_0/fix_case_of_hr_module_def.py index 21edb5861a8..f7120b8c2a7 100644 --- a/erpnext/patches/v4_0/fix_case_of_hr_module_def.py +++ b/erpnext/patches/v4_0/fix_case_of_hr_module_def.py @@ -1,5 +1,4 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# MIT License. See license.txt from __future__ import unicode_literals import frappe diff --git a/erpnext/patches/v4_0/new_address_template.py b/erpnext/patches/v4_0/new_address_template.py index 74b32b968c2..cebfa9a5366 100644 --- a/erpnext/patches/v4_0/new_address_template.py +++ b/erpnext/patches/v4_0/new_address_template.py @@ -2,9 +2,7 @@ import frappe def execute(): frappe.reload_doc("utilities", "doctype", "address_template") - d = frappe.new_doc("Address Template") - d.update({"country":frappe.db.get_default("country")}) - try: + if not frappe.db.sql("select name from `tabAddress Template`"): + d = frappe.new_doc("Address Template") + d.update({"country":frappe.db.get_default("country")}) d.insert() - except Exception: - pass diff --git a/erpnext/utilities/doctype/address_template/address_template.json b/erpnext/utilities/doctype/address_template/address_template.json index 378474e4cce..ba512fc6986 100644 --- a/erpnext/utilities/doctype/address_template/address_template.json +++ b/erpnext/utilities/doctype/address_template/address_template.json @@ -1,57 +1,57 @@ { - "autoname": "field:country", - "creation": "2014-06-05 02:22:36.029850", - "docstatus": 0, - "doctype": "DocType", - "document_type": "Master", + "autoname": "field:country", + "creation": "2014-06-05 02:22:36.029850", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", "fields": [ { - "fieldname": "country", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Country", - "options": "Country", - "permlevel": 0, - "reqd": 0, + "fieldname": "country", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Country", + "options": "Country", + "permlevel": 0, + "reqd": 1, "search_index": 1 - }, + }, { - "description": "This format is used if country specific format is not found", - "fieldname": "is_default", - "fieldtype": "Check", - "in_list_view": 1, - "label": "Is Default", + "description": "This format is used if country specific format is not found", + "fieldname": "is_default", + "fieldtype": "Check", + "in_list_view": 1, + "label": "Is Default", "permlevel": 0 - }, + }, { - "default": "{% if address_line2 %}{{ address_line2 }}
{% endif -%}\n{{ city }}
\n{% if state %}{{ state }}
{% endif -%}\n{% if pincode %} PIN: {{ pincode }}
{% endif -%}\n{{ country }}
\n{% if phone %}Phone: {{ phone }}
{% endif -%}\n{% if fax %}Fax: {{ fax }}
{% endif -%}\n{% if email_id %}Email: {{ email_id }}
{% endif -%}\n", - "description": "

Default Template

\n

Uses Jinja Templating and all the fields of Address (including Custom Fields if any) will be available

\n
{{ address_line1 }}<br>\n{% if address_line2 %}{{ address_line2 }}<br>{% endif -%}\n{{ city }}<br>\n{% if state %}{{ state }}<br>{% endif -%}\n{% if pincode %} PIN:  {{ pincode }}<br>{% endif -%}\n{{ country }}<br>\n{% if phone %}Phone: {{ phone }}<br>{% endif -%}\n{% if fax %}Fax: {{ fax }}<br>{% endif -%}\n{% if email_id %}Email: {{ email_id }}<br>{% endif -%}\n
", - "fieldname": "template", - "fieldtype": "Code", - "label": "Template", + "default": "{{ address_line1 }}
{% if address_line2 %}{{ address_line2 }}
{% endif -%}\n{{ city }}
\n{% if state %}{{ state }}
{% endif -%}\n{% if pincode %}PIN: {{ pincode }}
{% endif -%}\n{{ country }}
\n{% if phone %}Phone: {{ phone }}
{% endif -%}\n{% if fax %}Fax: {{ fax }}
{% endif -%}\n{% if email_id %}Email: {{ email_id }}
{% endif -%}\n", + "description": "

Default Template

\n

Uses Jinja Templating and all the fields of Address (including Custom Fields if any) will be available

\n
{{ address_line1 }}<br>\n{% if address_line2 %}{{ address_line2 }}<br>{% endif -%}\n{{ city }}<br>\n{% if state %}{{ state }}<br>{% endif -%}\n{% if pincode %} PIN:  {{ pincode }}<br>{% endif -%}\n{{ country }}<br>\n{% if phone %}Phone: {{ phone }}<br>{% endif -%}\n{% if fax %}Fax: {{ fax }}<br>{% endif -%}\n{% if email_id %}Email: {{ email_id }}<br>{% endif -%}\n
", + "fieldname": "template", + "fieldtype": "Code", + "label": "Template", "permlevel": 0 } - ], - "icon": "icon-map-marker", - "modified": "2014-06-05 06:14:13.200689", - "modified_by": "Administrator", - "module": "Utilities", - "name": "Address Template", - "name_case": "", - "owner": "Administrator", + ], + "icon": "icon-map-marker", + "modified": "2014-06-05 06:14:15.200689", + "modified_by": "Administrator", + "module": "Utilities", + "name": "Address Template", + "name_case": "", + "owner": "Administrator", "permissions": [ { - "create": 1, - "delete": 1, - "export": 1, - "permlevel": 0, - "read": 1, - "report": 1, - "role": "System Manager", - "set_user_permissions": 1, + "create": 1, + "delete": 1, + "export": 1, + "permlevel": 0, + "read": 1, + "report": 1, + "role": "System Manager", + "set_user_permissions": 1, "write": 1 } - ], - "sort_field": "modified", + ], + "sort_field": "modified", "sort_order": "DESC" -} \ No newline at end of file +}