Merge pull request #5760 from saurabh6790/is_group_fixes

[fix] patch fix for fieldtype change from select to check for is_group
This commit is contained in:
Rushabh Mehta 2016-07-14 18:58:50 +05:30 committed by GitHub
commit cd2ee8940b

View File

@ -1,13 +1,18 @@
from __future__ import unicode_literals
import frappe import frappe
def execute(): def execute():
for doctype in ["Sales Person", "Customer Group", "Item Group", "Territory"]: for doctype in ["Sales Person", "Customer Group", "Item Group", "Territory"]:
# convert to 1 or 0
frappe.db.sql("update `tab{doctype}` set is_group = if(is_group='Yes',1,0) "
.format(doctype=doctype))
frappe.db.commit()
# alter fields to int
frappe.db.sql("alter table `tab{doctype}` change is_group is_group int(1) default '0'"
.format(doctype=doctype))
frappe.reload_doctype(doctype) frappe.reload_doctype(doctype)
#In MySQL, you can't modify the same table which you use in the SELECT part.
frappe.db.sql(""" update `tab{doctype}` set is_group = 1
where name in (select parent_{field} from (select distinct parent_{field} from `tab{doctype}`
where parent_{field} != '') as dummy_table)
""".format(doctype=doctype, field=doctype.strip().lower().replace(' ','_')))