Example #1
0
	def validate(self):
		from frappe.custom.doctype.customize_form.customize_form import CustomizeForm

		meta = frappe.get_meta(self.dt, cached=False)
		fieldnames = [df.fieldname for df in meta.get("fields")]

		if self.insert_after=='append':
			self.insert_after = fieldnames[-1]

		if self.insert_after and self.insert_after in fieldnames:
			self.idx = fieldnames.index(self.insert_after) + 1

		old_fieldtype = self.db_get('fieldtype')
		is_fieldtype_changed = (not self.is_new()) and (old_fieldtype != self.fieldtype)

		if is_fieldtype_changed and not CustomizeForm.allow_fieldtype_change(old_fieldtype, self.fieldtype):
			frappe.throw(_("Fieldtype cannot be changed from {0} to {1}").format(old_fieldtype, self.fieldtype))

		if not self.fieldname:
			frappe.throw(_("Fieldname not set for Custom Field"))

		if self.get('translatable', 0) and not supports_translation(self.fieldtype):
			self.translatable = 0

		if not self.flags.ignore_validate:
			from frappe.core.doctype.doctype.doctype import check_if_fieldname_conflicts_with_methods
			check_if_fieldname_conflicts_with_methods(self.dt, self.fieldname)
	def validate(self):
		meta = frappe.get_meta(self.dt, cached=False)
		fieldnames = [df.fieldname for df in meta.get("fields")]

		if self.insert_after=='append':
			self.insert_after = fieldnames[-1]

		if self.insert_after and self.insert_after in fieldnames:
			self.idx = fieldnames.index(self.insert_after) + 1

		self._old_fieldtype = self.db_get('fieldtype')

		if not self.fieldname:
			frappe.throw(_("Fieldname not set for Custom Field"))

		if not self.flags.ignore_validate:
			from frappe.core.doctype.doctype.doctype import check_if_fieldname_conflicts_with_methods
			check_if_fieldname_conflicts_with_methods(self.dt, self.fieldname)
Example #3
0
	def validate(self):
		meta = frappe.get_meta(self.dt, cached=False)
		fieldnames = [df.fieldname for df in meta.get("fields")]

		if self.insert_after=='append':
			self.insert_after = fieldnames[-1]

		if self.insert_after and self.insert_after in fieldnames:
			self.idx = fieldnames.index(self.insert_after) + 1

		self._old_fieldtype = self.db_get('fieldtype')

		if not self.fieldname:
			frappe.throw(_("Fieldname not set for Custom Field"))

		if not self.flags.ignore_validate:
			from frappe.core.doctype.doctype.doctype import check_if_fieldname_conflicts_with_methods
			check_if_fieldname_conflicts_with_methods(self.dt, self.fieldname)