'create email flag queue'

def onload(self):

    if ((self.communication_type == u'Communication') and (self.communication_medium == u'Email') and (self.sent_or_received == u'Received') and self.uid and (self.uid != (-1))):
        flag = frappe.db.get_value(u'Email    Flag    Queue', {u'communication': self.name, u'is_completed': 0})
        if flag:
            return
        frappe.get_doc({u'doctype': u'Email    Flag    Queue', u'action': u'Read', u'communication': self.name, u'flag': u'(\\SEEN)', u'uid': self.uid, u'email_account': self.email_account}).insert(ignore_permissions=True)
        frappe.db.commit()
