Beispiel #1
0
	def apply_property_setters(self):
		"""
		Property Setters are set via Customize Form. They override standard properties
		of the doctype or its child properties like fields, links etc. This method
		applies the customized properties over the standard meta object
		"""
		if not frappe.db.table_exists('Property Setter'):
			return

		property_setters = frappe.db.sql("""select * from `tabProperty Setter` where
			doc_type=%s""", (self.name,), as_dict=1)

		if not property_setters: return

		for ps in property_setters:
			if ps.doctype_or_field=='DocType':
				self.set(ps.property, cast_fieldtype(ps.property_type, ps.value))

			elif ps.doctype_or_field=='DocField':
				for d in self.fields:
					if d.fieldname == ps.field_name:
						d.set(ps.property, cast_fieldtype(ps.property_type, ps.value))
						break

			elif ps.doctype_or_field=='DocType Link':
				for d in self.links:
					if d.name == ps.row_name:
						d.set(ps.property, cast_fieldtype(ps.property_type, ps.value))
						break

			elif ps.doctype_or_field=='DocType Action':
				for d in self.actions:
					if d.name == ps.row_name:
						d.set(ps.property, cast_fieldtype(ps.property_type, ps.value))
						break
Beispiel #2
0
def _cast_result(doctype, result):
    batch = []

    try:
        for field, value in result:
            df = frappe.get_meta(doctype).get_field(field)
            if df:
                value = cast_fieldtype(df.fieldtype, value)

            batch.append(tuple([field, value]))
    except frappe.exceptions.DoesNotExistError:
        return result

    return tuple(batch)
Beispiel #3
0
def _cast_result(doctype, result):
	batch = [ ]

	try:
		for field, value in result:
			df = frappe.get_meta(doctype).get_field(field)
			if df:
				value = cast_fieldtype(df.fieldtype, value)

			batch.append(tuple([field, value]))
	except frappe.exceptions.DoesNotExistError:
		return result

	return tuple(batch)
Beispiel #4
0
	def cast(self, value, df):
		return cast_fieldtype(df.fieldtype, value)
Beispiel #5
0
	def cast(self, value, df):
		return cast_fieldtype(df.fieldtype, value)
 def cast(self, value, df):
     return cast_fieldtype(df.fieldtype, value, show_warning=False)