Fix _idx property as per renamed fields

This commit is contained in:
Nabin Hait 2015-05-27 13:02:40 +05:30
parent 5b8db3729c
commit 5b731ff73a
2 changed files with 21 additions and 0 deletions

View File

@ -16,6 +16,9 @@ def execute():
for name, script in frappe.db.sql("select name, {0} as script from `tab{1}` where ({2}) {3}".format(script_field, dt, cond1, cond2)):
update_script(dt, name, script_field, script, renamed_fields)
# update fieldnames in property setter for idx
update_idx_property(renamed_fields)
def get_all_renamed_fields():
from erpnext.patches.v5_0.rename_table_fieldnames import rename_map
@ -63,3 +66,20 @@ def update_script(dt, name, script_field, script, renamed_fields):
script = re.sub(r"\bentries\b", "items", script)
frappe.db.set_value(dt, name, script_field, script)
def update_idx_property(renamed_fields):
for ps, ordered_fields, dt in frappe.db.sql("select name, value, doc_type from `tabProperty Setter` where property = '_idx'"):
for from_field, to_field in renamed_fields:
if from_field in ordered_fields:
ordered_fields[ordered_fields.index(from_field)] = to_field
# remove invalid fields
valid_fields = [f.fieldname for f in frappe.get_meta(dt).fields]
for fld in ordered_fields:
if fld not in valid_fields:
ordered_fields.pop(fld)
frappe.db.set_value("Property Setter", ps, "value", ordered_fields)
frappe.db.sql("delete from `tabProperty Setter` where `property` = 'idx'")

View File

@ -4,4 +4,5 @@ def execute():
frappe.reload_doctype("System Settings")
ss = frappe.get_doc("System Settings", "System Settings")
ss.email_footer_address = frappe.db.get_default("company")
ss.flags.ignore_mandatory = True
ss.save()