コード例 #1
0
	def get_label_and_type(self, from_dt, to_dt):
		"""get label, fieldtype"""
		from_flds, to_flds = {}, {}
		for d in get(from_dt, 0):
			from_flds[d.fieldname] = {'label': d.label, 'fieldtype': d.fieldtype}

		for d in get(to_dt, 0):
			to_flds[d.fieldname] = {'label': d.label, 'fieldtype': d.fieldtype}

		return from_flds, to_flds
コード例 #2
0
    def get_label_and_type(self, from_dt, to_dt):
        """get label, fieldtype"""
        from_flds, to_flds = {}, {}
        for d in get(from_dt, 0):
            from_flds[d.fieldname] = {
                'label': d.label,
                'fieldtype': d.fieldtype
            }

        for d in get(to_dt, 0):
            to_flds[d.fieldname] = {'label': d.label, 'fieldtype': d.fieldtype}

        return from_flds, to_flds
コード例 #3
0
	def check_fields_in_dt(self):
		"""
			Check if any wrong fieldname entered in mapper
		"""
		flds = {}
		for t in getlist(self.doclist, 'table_mapper_details'):
			from_flds = [cstr(d.fieldname) for d in get(t.from_table, 0)]
			to_flds = [cstr(d.fieldname) for d in get(t.to_table, 0)]
			flds[cstr(t.match_id)] = [cstr(t.from_table), from_flds, cstr(t.to_table), to_flds]

		for d in getlist(self.doclist, 'field_mapper_details'):
			# Default fields like name, parent, owner does not exists in DocField
			if d.from_field not in flds[cstr(d.match_id)][1] and d.from_field not in default_fields:
				msgprint("'%s' does not exists in DocType: '%s'" % (cstr(d.from_field), cstr(flds[cstr(d.match_id)][0])))
			if d.to_field not in flds[cstr(d.match_id)][3] and d.to_field not in default_fields:
				msgprint("'%s' does not exists in DocType: '%s'" % (cstr(d.to_field), cstr(flds[cstr(d.match_id)][2])))
コード例 #4
0
def validate_fields_for_doctype(doctype):
    from webnotes.model.doctype import get
    validate_fields(
        get(doctype, cached=False).get({
            "parent": doctype,
            "doctype": "DocField"
        }))
コード例 #5
0
def validate_permissions_for_doctype(doctype, for_remove=False):
    from webnotes.model.doctype import get
    validate_permissions(
        get(doctype, cached=False).get({
            "parent": doctype,
            "doctype": "DocPerm"
        }), for_remove)
コード例 #6
0
	def validate(self):
		from webnotes.model.doctype import get
		temp_doclist = get(self.doc.dt).get_parent_doclist()
				
		# set idx
		if not self.doc.idx:
			max_idx = max(d.idx for d in temp_doclist if d.doctype=='DocField')
			self.doc.idx = cint(max_idx) + 1
コード例 #7
0
ファイル: custom_field.py プロジェクト: Halfnhav/wnframework
	def validate(self):
		from webnotes.model.doctype import get
		temp_doclist = get(self.doc.dt).get_parent_doclist()
				
		# set idx
		if not self.doc.idx:
			max_idx = max(d.idx for d in temp_doclist if d.doctype=='DocField')
			self.doc.idx = cint(max_idx) + 1
コード例 #8
0
	def get_fields_with_same_name(self, t, flds):
		"""
			Returns field list with same name in from and to doctype
		"""
		import copy
		exception_flds = copy.copy(default_fields)
		exception_flds += [f[1] for f in flds]
		
		from_flds = [d.fieldname for d in get(t['from_table']).get_parent_doclist() \
			if cint(d.no_copy) == 0 and d.docstatus != 2 and d.fieldname \
			and d.fieldtype not in ('Table', 'Section Break', 'Column Break', 'HTML', 'Button')]

		to_flds = [d.fieldname for d in get(t['to_table']).get_parent_doclist() \
			if cint(d.no_copy) == 0 and d.docstatus != 2 and d.fieldname \
			and d.fieldtype not in ('Table', 'Section Break', 'Column Break', 'HTML', 'Button')]
		
		similar_flds = [[d, d, 'Yes'] for d in from_flds \
			if d in to_flds and d not in exception_flds]
						
		return similar_flds
コード例 #9
0
    def get_fields_with_same_name(self, t, flds):
        """
			Returns field list with same name in from and to doctype
		"""
        import copy
        exception_flds = copy.copy(default_fields)
        exception_flds += [f[1] for f in flds]

        from_flds = [d.fieldname for d in get(t['from_table']).get_parent_doclist() \
         if cint(d.no_copy) == 0 and d.docstatus != 2 and d.fieldname \
         and d.fieldtype not in ('Table', 'Section Break', 'Column Break', 'HTML', 'Button')]

        to_flds = [d.fieldname for d in get(t['to_table']).get_parent_doclist() \
         if cint(d.no_copy) == 0 and d.docstatus != 2 and d.fieldname \
         and d.fieldtype not in ('Table', 'Section Break', 'Column Break', 'HTML', 'Button')]

        similar_flds = [[d, d, 'Yes'] for d in from_flds \
         if d in to_flds and d not in exception_flds]

        return similar_flds
コード例 #10
0
	def get_ref_doclist(self):
		"""
			* Gets doclist of type self.doc.doc_type
			* Applies property setter properties on the doclist
			* returns the modified doclist
		"""
		from webnotes.model.doctype import get

		ref_doclist = get(self.doc.doc_type, form=0)

		return ref_doclist
コード例 #11
0
    def get_ref_doclist(self):
        """
			* Gets doclist of type self.doc.doc_type
			* Applies property setter properties on the doclist
			* returns the modified doclist
		"""
        from webnotes.model.doctype import get

        ref_doclist = get(self.doc.doc_type)
        ref_doclist = webnotes.doclist([ref_doclist[0]] + ref_doclist.get({"parent": self.doc.doc_type}))

        return ref_doclist
コード例 #12
0
    def get_ref_doclist(self):
        """
			* Gets doclist of type self.doc.doc_type
			* Applies property setter properties on the doclist
			* returns the modified doclist
		"""
        from webnotes.model.doctype import get

        ref_doclist = get(self.doc.doc_type)
        ref_doclist = webnotes.doclist(
            [ref_doclist[0]] + ref_doclist.get({"parent": self.doc.doc_type}))

        return ref_doclist
コード例 #13
0
ファイル: custom_field.py プロジェクト: NorrWing/wnframework
	def validate(self):
		self.set_fieldname()
		
		from webnotes.model.doctype import get
		temp_doclist = get(self.doc.dt, form=0)
		
		self.validate_field(temp_doclist)
		
		# set idx
		if not self.doc.idx:
			from webnotes.utils import cint
			max_idx = max(d.idx for d in temp_doclist if d.doctype=='DocField')
			self.doc.idx = cint(max_idx) + 1
コード例 #14
0
    def check_fields_in_dt(self):
        """
			Check if any wrong fieldname entered in mapper
		"""
        flds = {}
        for t in getlist(self.doclist, 'table_mapper_details'):
            from_flds = [cstr(d.fieldname) for d in get(t.from_table, 0)]
            to_flds = [cstr(d.fieldname) for d in get(t.to_table, 0)]
            flds[cstr(t.match_id)] = [
                cstr(t.from_table), from_flds,
                cstr(t.to_table), to_flds
            ]

        for d in getlist(self.doclist, 'field_mapper_details'):
            # Default fields like name, parent, owner does not exists in DocField
            if d.from_field not in flds[cstr(
                    d.match_id)][1] and d.from_field not in default_fields:
                msgprint("'%s' does not exists in DocType: '%s'" %
                         (cstr(d.from_field), cstr(flds[cstr(d.match_id)][0])))
            if d.to_field not in flds[cstr(
                    d.match_id)][3] and d.to_field not in default_fields:
                msgprint("'%s' does not exists in DocType: '%s'" %
                         (cstr(d.to_field), cstr(flds[cstr(d.match_id)][2])))
コード例 #15
0
def assign_idx(cf):
	from webnotes.model.doctype import get
	from webnotes.utils import cint
	#print len(cf)
	for f in cf:
		#print f.get('dt'), f.get('name')
		if f.get('idx'): continue
		temp_doclist = get(f.get('dt'), form=0)
		#print len(temp_doclist)
		max_idx = max(d.idx for d in temp_doclist if d.doctype=='DocField')
		if not max_idx: continue
		webnotes.conn.sql("""\
			UPDATE `tabCustom Field` SET idx=%s
			WHERE name=%s""", (cint(max_idx)+1, f.get('name')))
コード例 #16
0
def assign_idx(cf):
	from webnotes.model.doctype import get
	from webnotes.utils import cint
	#print len(cf)
	for f in cf:
		#print f.get('dt'), f.get('name')
		if f.get('idx'): continue
		temp_doclist = get(f.get('dt'), form=0)
		#print len(temp_doclist)
		max_idx = max(d.idx for d in temp_doclist if d.doctype=='DocField')
		if not max_idx: continue
		webnotes.conn.sql("""\
			UPDATE `tabCustom Field` SET idx=%s
			WHERE name=%s""", (cint(max_idx)+1, f.get('name')))
コード例 #17
0
ファイル: export_file.py プロジェクト: Yellowen/wnframework
def filter_fields(doc):
	from webnotes.model.doctype import get
	from webnotes.model import default_fields

	doctypelist = get(doc.doctype, False)
	valid_fields = [d.fieldname for d in doctypelist.get({"parent":doc.doctype,
		"doctype":"DocField"})]
	to_remove = []
	
	for key in doc:
		if (not key in default_fields) and (not key in valid_fields):
			to_remove.append(key)
		elif doc[key]==None:
			to_remove.append(key)
			
	for key in to_remove:
		del doc[key]
	
	return doc
コード例 #18
0
def filter_fields(doc):
    from webnotes.model.doctype import get
    from webnotes.model import default_fields

    doctypelist = get(doc.doctype, False)
    valid_fields = [
        d.fieldname for d in doctypelist.get({
            "parent": doc.doctype,
            "doctype": "DocField"
        })
    ]
    to_remove = []

    for key in doc:
        if (not key in default_fields) and (not key in valid_fields):
            to_remove.append(key)
        elif doc[key] == None:
            to_remove.append(key)

    for key in to_remove:
        del doc[key]

    return doc
コード例 #19
0
ファイル: doctype.py プロジェクト: masums/wnframework
def validate_fields_for_doctype(doctype):
    from webnotes.model.doctype import get
    validate_fields(
        filter(lambda d: d.doctype == "DocField" and d.parent == doctype,
               get(doctype)))
コード例 #20
0
ファイル: doctype.py プロジェクト: rohitw1991/latestadbwnf
def validate_permissions_for_doctype(doctype, for_remove=False):
	from webnotes.model.doctype import get
	validate_permissions(get(doctype, cached=False).get({"parent":doctype, 
		"doctype":"DocPerm"}), for_remove)
コード例 #21
0
ファイル: doctype.py プロジェクト: rohitw1991/latestadbwnf
def validate_fields_for_doctype(doctype):
	from webnotes.model.doctype import get
	validate_fields(get(doctype, cached=False).get({"parent":doctype, 
		"doctype":"DocField"}))
コード例 #22
0
def validate_fields_for_doctype(doctype):
	from webnotes.model.doctype import get
	validate_fields(filter(lambda d: d.doctype=="DocField" and d.parent==doctype, 
		get(doctype, cached=False)))