From 38e73da092f3bb3377edac983aea37aceed4ed3f Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Fri, 29 Dec 2017 12:18:58 +0100 Subject: [IMP] web: support variable digits In v10, a `Float` field with `widget="monetary"` option uses the decimal precision of the field. In v11, however, it uses the decimal precision of the currency. However, in many cases `widget="monetary"` is used in the sole purpose of displaying the currency symbol. The precision of the field sould be kept. This commit introduces the support of the decimal precision of the field for this specific use case thanks to the `field_digits` option: ``` ``` If such an option is used, the field precision will prevail over the currency precision. Related to #21686 opw-800279 --- addons/web/static/src/js/fields/basic_fields.js | 1 + 1 file changed, 1 insertion(+) (limited to 'addons/web/static/src/js/fields/basic_fields.js') diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index e823278463a..09406b43711 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -568,6 +568,7 @@ var FieldMonetary = InputField.extend({ this.formatOptions.currency = this.currency; this.formatOptions.digits = [16, 2]; + this.formatOptions.field_digits = this.nodeOptions.field_digits; }, //-------------------------------------------------------------------------- -- cgit v1.2.3 From 255e8ca3d92e3a77d7c2a145677623518bc2f978 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20Ku=CC=88hn?= Date: Fri, 5 Jan 2018 15:00:57 +0100 Subject: [FIX] web: binary field format in list view Binary fields were simply shown simply by their textual representation in list views, e.g. the base64 string. There was no formatter for binary fields, therefore it has been implemented so that it displays its estimated size. Binary fields in list views had a download link in v10.0. We provide this feature back by means of a widget called 'download_link'. It is also possible to define an option to set the field name having the filename as its value. Example: with the following record: {fname: 'document.txt', datas: 'Cg=='}, we get a file named "document.txt" by clicking on the download link. Closes #21996 --- addons/web/static/src/js/fields/basic_fields.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'addons/web/static/src/js/fields/basic_fields.js') diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index 09406b43711..38fc0cad439 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -1298,6 +1298,25 @@ var FieldBinaryFile = AbstractFieldBinary.extend({ }, }); +var FieldBinaryDownloadLink = AbstractFieldBinary.extend({ + template: 'FieldBinaryDownloadLink', + events: _.extend({}, AbstractFieldBinary.prototype.events, { + 'click': function (ev) { + ev.stopPropagation(); + }, + }), + supportedFieldTypes: ['binary'], + init: function () { + this._super.apply(this, arguments); + this.filename = _t("Binary File"); + if (this.nodeOptions.filename && this.recordData[this.nodeOptions.filename]) { + this.filename = this.recordData[this.nodeOptions.filename]; + } + this.url = "data:application/octet-stream;base64," + this.value; + this.text = _t("Download"); + }, +}); + var PriorityWidget = AbstractField.extend({ // the current implementation of this widget makes it // only usable for fields of type selection @@ -2528,6 +2547,7 @@ return { TranslatableFieldMixin: TranslatableFieldMixin, DebouncedField: DebouncedField, FieldEmail: FieldEmail, + FieldBinaryDownloadLink: FieldBinaryDownloadLink, FieldBinaryFile: FieldBinaryFile, FieldBinaryImage: FieldBinaryImage, FieldBoolean: FieldBoolean, -- cgit v1.2.3