patch for removing the address field from company and creating address doc, fixes #9011

This commit is contained in:
Manas Solanki 2017-06-21 16:52:49 +05:30
parent 3fe5ecc611
commit cdba021802
2 changed files with 34 additions and 0 deletions

View File

@ -406,6 +406,7 @@ erpnext.patches.v8_0.change_in_words_varchar_length
erpnext.patches.v8_0.update_stock_qty_value_in_bom_item
erpnext.patches.v8_0.create_domain_docs #16-05-2017
erpnext.patches.v8_0.update_sales_cost_in_project
erpnext.patches.v8_0.create_address_doc_from_address_field_in_company #10-05-2017
erpnext.patches.v8_0.save_system_settings
erpnext.patches.v8_1.delete_deprecated_reports
erpnext.patches.v8_1.setup_gst_india #2017-06-27

View File

@ -0,0 +1,33 @@
# Copyright (c) 2017, Frappe and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
# new field address_html is created in place of address field for the company's address
# patch for moving the address details in the address doc
company_list = []
if frappe.db.sql("SHOW COLUMNS FROM `tabCompany` LIKE 'address'"):
company_list = frappe.db.sql('''select name, address from `tabCompany` where address is not null''', as_dict=1)
for company in company_list:
add_list = company.address.split(" ")
if ',' in company.address:
add_list = company.address.rpartition(',')
elif ' ' in company.address:
add_list = company.address.rpartition(' ')
else:
add_list = [company.address, None, company.address]
doc = frappe.get_doc({
"doctype":"Address",
"address_line1": add_list[0],
"city": add_list[2],
"is_your_company_address":1,
"links": [{
"link_doctype": "Company",
"link_name": company.name
}]
})
doc.save()