Merge pull request #7014 from rohitwaghchaure/rename_autoname_field

patch for rename autoname field
This commit is contained in:
Nabin Hait 2016-11-21 19:04:44 +05:30 committed by GitHub
commit 376e8945f7
2 changed files with 15 additions and 0 deletions

View File

@ -349,3 +349,4 @@ erpnext.patches.v7_0.set_base_amount_in_invoice_payment_table
erpnext.patches.v7_1.update_invoice_status
erpnext.patches.v7_0.po_status_issue_for_pr_return
erpnext.patches.v7_1.update_missing_salary_component_type
erpnext.patches.v7_0.update_autoname_field

View File

@ -0,0 +1,14 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
doctypes = frappe.db.sql(""" select name, autoname from `tabDocType`
where autoname like 'field:%' and allow_rename = 1""", as_dict=1)
for doctype in doctypes:
fieldname = doctype.autoname.split(":")[1]
if fieldname:
frappe.db.sql(""" update `tab%s` set %s = name """%(doctype.name, fieldname))