[minor] [fix] precision for float fields on server-side

This commit is contained in:
Anand Doshi 2013-08-12 11:58:01 +05:30
parent f5727e4834
commit a7cf1df5a9
3 changed files with 9 additions and 6 deletions

View file

@ -26,7 +26,7 @@ $(cur_frm.wrapper).on("grid-row-render", function(e, grid_row) {
}
})
cur_frm.cscript.doc_type = function(doc, dt, dn) {
cur_frm.cscript.doc_type = function() {
return cur_frm.call({
method: "get",
doc: cur_frm.doc,

View file

@ -116,14 +116,14 @@ window.format_number = function(v, format, decimals){
return (is_negative ? "-" : "") + part[0] + part[1];
};
function format_currency(v, currency) {
function format_currency(v, currency, decimals) {
var format = get_number_format(currency);
var symbol = get_currency_symbol(currency);
if(symbol)
return symbol + " " + format_number(v, format);
return symbol + " " + format_number(v, format, decimals);
else
return format_number(v, format);
return format_number(v, format, decimals);
}
function get_currency_symbol(currency) {

View file

@ -101,7 +101,10 @@ class DocListController(object):
if df.fieldtype == "Currency" and df.options and not self._precision.options.get(df.options):
self._precision.options[df.options] = get_field_precision(df, self.doc)
self._precision[parentfield or "main"][fieldname] = cint(self._precision.options.get(df.options)) or \
self._precision.default
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":
self._precision[parentfield or "main"][fieldname] = self._precision.default
return self._precision[parentfield or "main"][fieldname]