'Fetch Parent Details and validate parent account'

def validate_parent(self):

    if self.parent_account:
        par = frappe.db.get_value(u'Account', self.parent_account, [u'name', u'is_group', u'company'], as_dict=1)
        if (not par):
            throw(_(u'Account    {0}:    Parent    account    {1}    does    not    exist').format(self.name, self.parent_account))
        elif (par.name == self.name):
            throw(_(u'Account    {0}:    You    can    not    assign    itself    as    parent    account').format(self.name))
        elif (not par.is_group):
            throw(_(u'Account    {0}:    Parent    account    {1}    can    not    be    a    ledger').format(self.name, self.parent_account))
        elif (par.company != self.company):
            throw(_(u'Account    {0}:    Parent    account    {1}    does    not    belong    to    company:    {2}').format(self.name, self.parent_account, self.company))
