summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/fields/field_utils.js
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2018-01-10 11:41:35 +0100
committerChristophe Simonis <chs@odoo.com>2018-01-10 11:41:35 +0100
commit228ecdbe28246b0031a9cf7e63b90f4ae11131df (patch)
tree33a3c3807c98ee79352abce486decd365e33b1b9 /addons/web/static/src/js/fields/field_utils.js
parent8270b212909de5cb26e958c023a4f0a27947eeef (diff)
parentff0abd214c89dce19984ed0f3c72ea556e23da01 (diff)
[MERGE] forward port branch 11.0 up to ff0abd214c8
Diffstat (limited to 'addons/web/static/src/js/fields/field_utils.js')
-rw-r--r--addons/web/static/src/js/fields/field_utils.js22
1 files changed, 20 insertions, 2 deletions
diff --git a/addons/web/static/src/js/fields/field_utils.js b/addons/web/static/src/js/fields/field_utils.js
index 932ea997e6a..812a7f380f7 100644
--- a/addons/web/static/src/js/fields/field_utils.js
+++ b/addons/web/static/src/js/fields/field_utils.js
@@ -28,6 +28,20 @@ var _t = core._t;
//------------------------------------------------------------------------------
/**
+ *
+ * @param {string} value base64 representation of the binary
+ * @param {Object} [field]
+ * a description of the field (note: this parameter is ignored)
+ * @param {Object} [options] additional options (note: this parameter is ignored)
+ */
+function formatBinary(value, field, options) {
+ if (!value) {
+ return '';
+ }
+ return utils.human_size(value.length / 1.37); // base64 estimated size: http://en.wikipedia.org/wiki/Base64#MIME
+}
+
+/**
* @todo Really? it returns a jQuery element... We should try to avoid this and
* let DOM utility functions handle this directly. And replace this with a
* function that returns a string so we can get rid of the forceString.
@@ -286,8 +300,12 @@ function formatMonetary(value, field, options) {
currency = session.get_currency(currency_id);
}
+ var digits = (currency && currency.digits) || options.digits;
+ if (options.field_digits === true) {
+ digits = field.digits || digits;
+ }
var formatted_value = formatFloat(value, field, {
- digits: (currency && currency.digits) || options.digits,
+ digits: digits,
});
if (!currency || options.noSymbol) {
@@ -557,7 +575,7 @@ function parseMany2one(value) {
return {
format: {
- binary: _.identity, // todo
+ binary: formatBinary,
boolean: formatBoolean,
char: formatChar,
date: formatDate,