'Validate invoice that c-form is applicable
and no other c-form is received for that'

def validate(self):

    for d in self.get(u'invoices'):
        if d.invoice_no:
            inv = frappe.db.sql(u'select    c_form_applicable,    c_form_no    from\n DCTB  DCTB  DCTB  DCTB  DCTB `tabSales    Invoice`    where    name    =    %s    and    docstatus    =    1', d.invoice_no)
            if (inv and (inv[0][0] != u'Yes')):
                frappe.throw(_(u'C-form    is    not    applicable    for    Invoice:    {0}'.format(d.invoice_no)))
            elif (inv and inv[0][1] and (inv[0][1] != self.name)):
                frappe.throw(_(u'Invoice    {0}    is    tagged    in    another    C-form:    {1}.\n DCTB  DCTB  DCTB  DCTB  DCTB  DCTB If    you    want    to    change    C-form    no    for    this    invoice,\n DCTB  DCTB  DCTB  DCTB  DCTB  DCTB please    remove    invoice    no    from    the    previous    c-form    and    then    try    again'.format(d.invoice_no, inv[0][1])))
            elif (not inv):
                frappe.throw(_(u'Row    {0}:    Invoice    {1}    is    invalid,    it    might    be    cancelled    /    does    not    exist.     DCTB  DCTB  DCTB  DCTB  DCTB  DCTB Please    enter    a    valid    Invoice'.format(d.idx, d.invoice_no)))
