[precision and currency] [fix] fix in get precision and display of currency

This commit is contained in:
Anand Doshi 2013-05-31 14:30:21 +05:30
parent a83ae1bd99
commit 2baa15d4a2
3 changed files with 5 additions and 3 deletions

View file

@ -120,7 +120,7 @@ function get_currency_symbol(currency) {
if(!currency)
currency = wn.boot.sysdefaults.currency;
return wn.model.get_value("Currency", currency, "symbol") || currency;
return wn.model.get_value(":Currency", currency, "symbol") || currency;
} else {
// load in template
return wn.currency_symbols[currency];
@ -161,5 +161,6 @@ function roundNumber(num, dec) {
function precision(fieldname, doc) {
if(!doc) doc = cur_frm.doc;
var df = wn.meta.get_docfield(doc.doctype, fieldname, doc.parent || doc.name);
if(!df) console.log(fieldname + ": could not find docfield in method precision()");
return wn.meta.get_field_precision(df, doc);
}

View file

@ -159,7 +159,7 @@ $.extend(wn.meta, {
get_field_precision: function(df, doc) {
var precision = wn.defaults.get_default("float_precision") || 6;
if(df.fieldtype === "Currency") {
if(df && df.fieldtype === "Currency") {
var currency = this.get_field_currency(df, doc);
var number_format = get_number_format(currency);
var number_format_info = get_number_format_info(number_format);

View file

@ -24,6 +24,7 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cstr
def get_dt_values(doctype, fields, as_dict = 0):
return webnotes.conn.sql('SELECT %s FROM tabDocType WHERE name="%s"' % (fields, doctype), as_dict = as_dict)
@ -88,7 +89,7 @@ def get_field_currency(df, doc):
"""get currency based on DocField options and fieldvalue in doc"""
currency = None
if ":" in df.options:
if ":" in cstr(df.options):
split_opts = df.options.split(":")
if len(split_opts)==3:
currency = webnotes.conn.get_value(split_opts[0], doc.fields.get(split_opts[1]),