diff --git a/public/js/legacy/utils/datatype.js b/public/js/legacy/utils/datatype.js
index 533dd7ecdd..ea6d1c245b 100644
--- a/public/js/legacy/utils/datatype.js
+++ b/public/js/legacy/utils/datatype.js
@@ -94,7 +94,7 @@ function is_null(v) {
}
function set_value_in(ele, v, ftype, fopt, doc) {
- $(ele).html(wn.format(v, {fieldtype:ftype, options:fopt}, doc));
+ $(ele).html(wn.format(v, {fieldtype:ftype, options:fopt}, null, doc));
return;
}
var $s = set_value_in; // used in print formats
diff --git a/public/js/legacy/widgets/form/fields.js b/public/js/legacy/widgets/form/fields.js
index fd4f824eb4..9023a71b6f 100644
--- a/public/js/legacy/widgets/form/fields.js
+++ b/public/js/legacy/widgets/form/fields.js
@@ -862,7 +862,7 @@ FloatField.prototype.onmake_input = function() {
}
}
FloatField.prototype.set_disp = function(val) {
- this.set_disp_html(wn.format(val, this.df, locals[this.doctype][this.name]));
+ this.set_disp_html(wn.format(val, this.df, null, locals[this.doctype][this.name]));
}
function PercentField() { } PercentField.prototype = new FloatField();
diff --git a/public/js/wn/form/formatters.js b/public/js/wn/form/formatters.js
index 604c8653be..e644bf06b5 100644
--- a/public/js/wn/form/formatters.js
+++ b/public/js/wn/form/formatters.js
@@ -19,7 +19,7 @@ wn.form.formatters = {
Percent: function(value) {
return cint(value) + "%";
},
- Currency: function(value, docfield, doc) {
+ Currency: function(value, docfield, options, doc) {
var currency = wn.meta.get_field_currency(docfield, doc);
return "
" + format_currency(value, currency) + "
";
},
@@ -95,7 +95,7 @@ wn.form.get_formatter = function(fieldtype) {
return wn.form.formatters[fieldtype.replace(/ /g, "")] || wn.form.formatters.Data;
}
-wn.format = function(value, df, options) {
+wn.format = function(value, df, options, doc) {
if(!df) df = {"fieldtype":"Data"};
- return wn.form.get_formatter(df.fieldtype)(value, df, options);
+ return wn.form.get_formatter(df.fieldtype)(value, df, options, doc);
}
\ No newline at end of file
diff --git a/public/js/wn/model/meta.js b/public/js/wn/model/meta.js
index a758d37e18..a15da03437 100644
--- a/public/js/wn/model/meta.js
+++ b/public/js/wn/model/meta.js
@@ -116,6 +116,10 @@ $.extend(wn.meta, {
var options = df.options.split(":");
if(options.length==3) {
// get reference record e.g. Company
+ var docname = doc[options[1]];
+ if(!docname) {
+ docname = cur_frm.doc[options[1]]
+ }
currency = wn.model.get_value(options[0], doc[options[1]],
options[2]) || currency;
}
diff --git a/public/js/wn/views/listview.js b/public/js/wn/views/listview.js
index b886d88de6..5046b9a9fd 100644
--- a/public/js/wn/views/listview.js
+++ b/public/js/wn/views/listview.js
@@ -262,7 +262,7 @@ wn.views.ListView = Class.extend({
}
else if(data[opts.content]) {
$("")
- .html(wn.format(data[opts.content], opts.df, data))
+ .html(wn.format(data[opts.content], opts.df, null, data))
.appendTo(parent)
}
diff --git a/public/js/wn/views/reportview.js b/public/js/wn/views/reportview.js
index 941127ae85..c70e722b21 100644
--- a/public/js/wn/views/reportview.js
+++ b/public/js/wn/views/reportview.js
@@ -183,7 +183,7 @@ wn.views.ReportView = wn.ui.Listing.extend({
width: (docfield ? cint(docfield.width) : 120) || 120,
formatter: function(row, cell, value, columnDef, dataContext) {
var docfield = columnDef.docfield;
- return wn.format(value, docfield, dataContext);
+ return wn.format(value, docfield, null, dataContext);
}
}
return coldef;