[minor] Percent

This commit is contained in:
Anand Doshi 2014-07-25 13:22:48 +05:30
parent b1e1d8362d
commit 536926cb12
5 changed files with 7 additions and 7 deletions

View file

@ -44,7 +44,7 @@ class CustomizeForm(Document):
'default': 'Text'
}
allowed_fieldtype_change = (('Currency', 'Float'), ('Small Text', 'Data'),
allowed_fieldtype_change = (('Currency', 'Float', 'Percent'), ('Small Text', 'Data'),
('Text', 'Text Editor', 'Code'), ('Data', 'Select'))
def on_update(self):

View file

@ -103,7 +103,7 @@ def upload(rows = None, submit_after_import=None, ignore_encoding_errors=False,
d[fieldname] = rows[idx][column_idx]
if fieldtype in ("Int", "Check"):
d[fieldname] = cint(d[fieldname])
elif fieldtype in ("Float", "Currency"):
elif fieldtype in ("Float", "Currency", "Percent"):
d[fieldname] = flt(d[fieldname])
elif fieldtype == "Date":
d[fieldname] = parse_date(d[fieldname]) if d[fieldname] else None

View file

@ -238,7 +238,7 @@ class BaseDocument(object):
if df.fieldtype == "Int":
self.set(df.fieldname, cint(self.get(df.fieldname)))
elif df.fieldtype in ("Float", "Currency"):
elif df.fieldtype in ("Float", "Currency", "Percent"):
self.set(df.fieldname, flt(self.get(df.fieldname)))
if self.docstatus is not None:

View file

@ -495,7 +495,7 @@ class Document(BaseDocument):
val1 = doc.get(fieldname)
if df.fieldtype in ("Currency", "Float"):
if df.fieldtype in ("Currency", "Float", "Percent"):
val1 = flt(val1, self.precision(df.fieldname, doc.parentfield or None))
val2 = flt(val2, self.precision(df.fieldname, doc.parentfield or None))
elif df.fieldtype in ("Int", "Check"):
@ -525,7 +525,7 @@ class Document(BaseDocument):
def round_floats_in(self, doc, fieldnames=None):
if not fieldnames:
fieldnames = (df.fieldname for df in
doc.meta.get("fields", {"fieldtype": ["in", ["Currency", "Float"]]}))
doc.meta.get("fields", {"fieldtype": ["in", ["Currency", "Float", "Percent"]]}))
for fieldname in fieldnames:
doc.set(fieldname, flt(doc.get(fieldname), self.precision(fieldname, doc.parentfield)))
@ -552,7 +552,7 @@ class Document(BaseDocument):
if df.fieldtype == "Currency":
self._precision[parentfield or "main"][fieldname] = cint(self._precision.options.get(df.options)) or \
self._precision.default
elif df.fieldtype == "Float":
elif df.fieldtype in ("Float", "Percent"):
self._precision[parentfield or "main"][fieldname] = self._precision.default
return self._precision[parentfield or "main"][fieldname]

View file

@ -128,7 +128,7 @@ def check_record(d):
d[key] = parse_date(val)
elif val and docfield.fieldtype in ["Int", "Check"]:
d[key] = cint(val)
elif val and docfield.fieldtype in ["Currency", "Float"]:
elif val and docfield.fieldtype in ["Currency", "Float", "Percent"]:
d[key] = flt(val)
def import_doc(d, doctype, overwrite, row_idx, submit=False, ignore_links=False):