def check_select_link_data(self, r, c, f, d, s='', l=''): from webnotes.model.doctype import get_field_property options = '' try: if d and f: dt = get_field_property(self.dt_list[0], f, 'options') lbl = get_field_property(self.dt_list[0], f, 'label') if dt: options = l and dt and [ n[0] for n in sql("select name from `tab%s` " % (('link:' in dt and dt[5:]) or dt)) ] or s and dt.split('\n') or '' if options and d not in options: msg = '<div style="color: RED">At Row ' + str( r ) + ' and Column ' + str(c) + ' : => Data "' + str( d) + '" in field [' + str(lbl) + '] Not Found in ' msg = msg.__add__( s and str('Select Options [' + str(dt.replace('\n', ',')) + ']') or str('Master ' + str('link:' in dt and dt[5:] or dt))) msg = msg.__add__('</div>\n') self.msg.append(msg) self.validate_success = 0 except Exception, e: self.msg.append('<div style="color: RED"> ERROR: %s </div>' % (str(webnotes.utils.getTraceback()))) self.validate_success = 0
def check_select_link_data(self, r, c, f, d, s = '', l = ''): from webnotes.model.doctype import get_field_property options = '' try: if d and f: dt = get_field_property(self.dt_list[0], f, 'options') lbl = get_field_property(self.dt_list[0], f, 'label') if dt: options = l and dt and [n[0] for n in sql("select name from `tab%s` " % (('link:' in dt and dt[5:]) or dt))] or s and dt.split('\n') or '' if options and d not in options : msg = '<div style="color: RED">At Row ' + str(r) + ' and Column ' + str(c)+ ' : => Data "' + str(d) + '" in field ['+ str(lbl) +'] Not Found in ' msg = msg.__add__( s and str( 'Select Options [' +str(dt.replace('\n', ',')) +']' ) or str('Master ' + str('link:' in dt and dt[5:] or dt))) msg = msg.__add__('</div>\n') self.msg.append(msg) self.validate_success = 0 except Exception, e: self.msg.append('<div style="color: RED"> ERROR: %s </div>' % (str(webnotes.utils.getTraceback()))) self.validate_success = 0
def get_template(): """download template""" template_type = webnotes.form_dict.get('type') from webnotes.model.doctype import get_field_property naming_options = get_field_property("Journal Voucher", "naming_series", "options") voucher_type = get_field_property("Journal Voucher", "voucher_type", "options") if template_type == "Two Accounts": extra_note = "" columns = '''"Naming Series","Voucher Type","Posting Date","Amount","Debit Account","Credit Account","Cost Center","Against Sales Invoice","Against Purchase Invoice","Against Journal Voucher","Remarks","Due Date","Ref Number","Ref Date"''' else: extra_note = ''' "5. Put the account head as Data label each in a new column" "6. Put the Debit amount as +ve and Credit amount as -ve"''' columns = '''"Naming Series","Voucher Type","Posting Date","Cost Center","Against Sales Invoice","Against Purchase Invoice","Against Journal Voucher","Remarks","Due Date","Ref Number","Ref Date"''' webnotes.response['result'] = '''"Voucher Import: %(template_type)s" "Each entry below will be a separate Journal Voucher." "Note:" "1. Dates in format: %(user_fmt)s" "2. Cost Center is required for Income or Expense accounts" "3. Naming Series Options: %(naming_options)s" "4. Voucher Type Options: %(voucher_type)s"%(extra_note)s "-------Common Values-----------" "Company:","%(default_company)s" "--------Data----------" %(columns)s ''' % { "template_type": template_type, "user_fmt": webnotes.conn.get_value('Control Panel', None, 'date_format'), "default_company": webnotes.conn.get_default("company"), "naming_options": naming_options.replace("\n", ", "), "voucher_type": voucher_type.replace("\n", ", "), "extra_note": extra_note, "columns": columns } webnotes.response['type'] = 'csv' webnotes.response['doctype'] = "Voucher-Import-%s" % template_type
def get_template(): """download template""" template_type = webnotes.form_dict.get('type') from webnotes.model.doctype import get_field_property naming_options = get_field_property("Journal Voucher", "naming_series", "options") voucher_type = get_field_property("Journal Voucher", "voucher_type", "options") if template_type=="Two Accounts": extra_note = "" columns = '''"Naming Series","Voucher Type","Posting Date","Amount","Debit Account","Credit Account","Cost Center","Against Sales Invoice","Against Purchase Invoice","Against Journal Voucher","Remarks","Due Date","Ref Number","Ref Date"''' else: extra_note = ''' "5. Put the account head as Data label each in a new column" "6. Put the Debit amount as +ve and Credit amount as -ve"''' columns = '''"Naming Series","Voucher Type","Posting Date","Cost Center","Against Sales Invoice","Against Purchase Invoice","Against Journal Voucher","Remarks","Due Date","Ref Number","Ref Date"''' webnotes.response['result'] = '''"Voucher Import: %(template_type)s" "Each entry below will be a separate Journal Voucher." "Note:" "1. Dates in format: %(user_fmt)s" "2. Cost Center is required for Income or Expense accounts" "3. Naming Series Options: %(naming_options)s" "4. Voucher Type Options: %(voucher_type)s"%(extra_note)s "-------Common Values-----------" "Company:","%(default_company)s" "--------Data----------" %(columns)s ''' % { "template_type": template_type, "user_fmt": webnotes.conn.get_value('Control Panel', None, 'date_format'), "default_company": webnotes.conn.get_default("company"), "naming_options": naming_options.replace("\n", ", "), "voucher_type": voucher_type.replace("\n", ", "), "extra_note": extra_note, "columns": columns } webnotes.response['type'] = 'csv' webnotes.response['doctype'] = "Voucher-Import-%s" % template_type