From 519555054a3a0e2e0b8a139518da081c4d5e80aa Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Mon, 4 Dec 2017 12:05:22 +0100 Subject: [FIX] web: BinaryFile not download when new record Let's have: - on res.company a binary file field named x_file - on res.users a related binary field to company_id.x_file, and make it readonly - On the res.users form view, display the new field Before this commit in create mode, upon clicking on download the file, the server crashed, because the record id was empty. Then, the JS crashed in turn because of the unhandled 404 from the server. Since the id of a new record will always be unset, we choose to disable the download option in this very specific case OPW 777042 --- addons/web/static/src/js/fields/basic_fields.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (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 069e004c702..deb5edfc922 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -1202,6 +1202,11 @@ var FieldBinaryFile = AbstractFieldBinary.extend({ this.$el.append(" " + this.filename_value); } } + if (!this.res_id) { + this.$el.css('cursor', 'not-allowed'); + } else { + this.$el.css('cursor', 'pointer'); + } }, _renderEdit: function () { if (this.value) { @@ -1226,7 +1231,7 @@ var FieldBinaryFile = AbstractFieldBinary.extend({ if (!this.value) { this.do_warn(_t("Save As..."), _t("The field is empty, there's nothing to save !")); ev.stopPropagation(); - } else { + } else if (this.res_id) { framework.blockUI(); var c = crash_manager; var filename_fieldname = this.attrs.filename; -- cgit v1.2.3