#NEWLINE# def execute( ) : #NEWLINE# #INDENT# frappe . reload_doctype ( 'Communication' ) #NEWLINE# for ( doctype , name ) in frappe . db . sql ( "select distinct reference_doctype, reference_name\n\t\tfrom `tabCommunication`\n\t\twhere\n\t\t\t(reference_doctype is not null and reference_doctype != '')\n\t\t\tand (reference_name is not null and reference_name != '')\n\t\t\tand (reference_owner is null or reference_owner = '')\n\t\tfor update" ) : #NEWLINE# #INDENT# owner = frappe . db . get_value ( doctype , name , 'owner' ) #NEWLINE# if ( not owner ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# frappe . db . sql ( "update `tabCommunication`\n\t\t\tset reference_owner=%(owner)s\n\t\t\twhere\n\t\t\t\treference_doctype=%(doctype)s\n\t\t\t\tand reference_name=%(name)s\n\t\t\t\tand (reference_owner is null or reference_owner = '')" . format ( doctype = doctype ) , { #NEWLINE# #INDENT# 'doctype' : owner , #NEWLINE# 'name' : name , #NEWLINE# 'owner' : owner , #NEWLINE# #UNINDENT# } ) #NEWLINE# frappe . db . commit ( )