'Returns float precision for a particular field (or get global default).
:param fieldname: Fieldname for which precision is required.
:param parentfield: If fieldname is in child table.'

def precision(self, fieldname, parentfield=None):

    from frappe.model.meta import get_field_precision
    if (parentfield and (not isinstance(parentfield, basestring))):
        parentfield = parentfield.parentfield
    cache_key = (parentfield or u'main')
    if (not hasattr(self, u'_precision')):
        self._precision = frappe._dict()
    if (cache_key not in self._precision):
        self._precision[cache_key] = frappe._dict()
    if (fieldname not in self._precision[cache_key]):
        self._precision[cache_key][fieldname] = None
        doctype = (self.meta.get_field(parentfield).options if parentfield else self.doctype)
        df = frappe.get_meta(doctype).get_field(fieldname)
        if (df.fieldtype in (u'Currency', u'Float', u'Percent')):
            self._precision[cache_key][fieldname] = get_field_precision(df, self)
    return self._precision[cache_key][fieldname]
