[fix] rename password field

This commit is contained in:
Anand Doshi 2016-06-15 16:44:13 +05:30
parent ac6053b47f
commit a47580b3bc
2 changed files with 10 additions and 0 deletions

View file

@ -6,6 +6,7 @@ from __future__ import unicode_literals
import frappe
import json
from frappe.model import no_value_fields
from frappe.utils.password import rename_password_field
def rename_field(doctype, old_fieldname, new_fieldname):
"""This functions assumes that doctype is already synced"""
@ -34,6 +35,10 @@ def rename_field(doctype, old_fieldname, new_fieldname):
update_reports(doctype, old_fieldname, new_fieldname)
update_users_report_view_settings(doctype, old_fieldname, new_fieldname)
if new_field.fieldtype == "Password":
rename_password_field(doctype, old_fieldname, new_fieldname)
# update in property setter
update_property_setters(doctype, old_fieldname, new_fieldname)

View file

@ -70,6 +70,11 @@ def rename_password(doctype, old_name, new_name):
where doctype=%(doctype)s and name=%(old_name)s""",
{ 'doctype': doctype, 'new_name': new_name, 'old_name': old_name })
def rename_password_field(doctype, old_fieldname, new_fieldname):
frappe.db.sql('''update `__Auth` set fieldname=%(new_fieldname)s
where doctype=%(doctype)s and fieldname=%(old_fieldname)s''',
{ 'doctype': doctype, 'old_fieldname': old_fieldname, 'new_fieldname': new_fieldname })
def create_auth_table():
# same as Framework.sql
frappe.db.sql_ddl("""create table if not exists __Auth (