'check in manage account if sales order / delivery note required or not.'

def so_dn_required(self):

    dic = {u'Sales    Order': [u'so_required', u'is_pos'], u'Delivery    Note': [u'dn_required', u'update_stock']}
    for i in dic:
        if (frappe.db.get_value(u'Selling    Settings', None, dic[i][0]) == u'Yes'):
            for d in self.get(u'items'):
                if ((frappe.db.get_value(u'Item', d.item_code, u'is_stock_item') == 1) and (not d.get(i.lower().replace(u'    ', u'_'))) and (not self.get(dic[i][1]))):
                    msgprint(_(u'{0}    is    mandatory    for    Item    {1}').format(i, d.item_code), raise_exception=1)
