def sync_customizations_for_doctype(data):
 from frappe.core.doctype.doctype.doctype import validate_fields_for_doctype
 doctype = data[u'doctype']
 def sync(key, custom_doctype, doctype_fieldname):
  frappe.db.sql(u'delete from `tab{0}` where `{1}`=%s'.format(custom_doctype, doctype_fieldname), doctype)
  for d in data[key]:
   d[u'doctype'] = custom_doctype
   doc = frappe.get_doc(d)
   doc.db_insert()
 if data[u'custom_fields']:
  sync(u'custom_fields', u'Custom Field', u'dt')
 if data[u'property_setters']:
  sync(u'property_setters', u'Property Setter', u'doc_type')
 if data.get(u'custom_perms'):
  sync(u'custom_perms', u'Custom DocPerm', u'parent')
 print u'Updating customizations for {0}'.format(doctype)
 validate_fields_for_doctype(doctype)

def sync_customizations_for_doctype ( data ) : from frappe . core . doctype . doctype . doctype import validate_fields_for_doctype doctype = data [ u'doctype' ] def sync ( key , custom_doctype , doctype_fieldname ) : frappe . db . sql ( u'delete from `tab{0}` where `{1}`=%s' . format ( custom_doctype , doctype_fieldname ) , doctype ) for d in data [ key ] : d [ u'doctype' ] = custom_doctype doc = frappe . get_doc ( d ) doc . db_insert ( ) if data [ u'custom_fields' ] : sync ( u'custom_fields' , u'Custom Field' , u'dt' ) if data [ u'property_setters' ] : sync ( u'property_setters' , u'Property Setter' , u'doc_type' ) if data . get ( u'custom_perms' ) : sync ( u'custom_perms' , u'Custom DocPerm' , u'parent' ) print u'Updating customizations for {0}' . format ( doctype ) validate_fields_for_doctype ( doctype )
sync doctype customzations for a particular data set .