get label from doctype's doclist

This commit is contained in:
Anand Doshi 2013-02-20 15:55:09 +05:30
parent 7075d36532
commit 61c60c5e52
2 changed files with 16 additions and 5 deletions

View file

@ -111,8 +111,17 @@ class Document:
def __str__(self):
return str(self.fields)
def __repr__(self):
return repr(self.fields)
def __unicode__(self):
return unicode(self.fields)
def __eq__(self, other):
return self.fields == other.fields
if isinstance(other, Document):
return self.fields == other.fields
else:
return False
def __getstate__(self):
return self.fields

View file

@ -72,7 +72,9 @@ def get_table_fields(doctype):
return child_tables + custom_child_tables
def has_field(doctype, fieldname):
doclist = webnotes.model.doctype.get(doctype)
return doclist.get({"parent":doctype, "doctype":"DocField", "fieldname":fieldname})
def has_field(doctype, fieldname, parent=None, parentfield=None):
return get_field(doctype, fieldname, parent=None, parentfield=None) and True or False
def get_field(doctype, fieldname, parent=None, parentfield=None):
doclist = webnotes.get_doctype(doctype)
return doclist.get_field(fieldname, parent, parentfield)