summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/fields/basic_fields.js
diff options
context:
space:
mode:
authorLucas Perais (lpe) <lpe@odoo.com>2017-12-04 12:05:22 +0100
committerLucas Perais (lpe) <lpe@odoo.com>2017-12-05 08:19:08 +0100
commit519555054a3a0e2e0b8a139518da081c4d5e80aa (patch)
tree347c2ad441d9bb9928602a5d72a0926f043b2536 /addons/web/static/src/js/fields/basic_fields.js
parenta8d01cbf4ea88f894ff927a6a5424bbb58e630d0 (diff)
[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
Diffstat (limited to 'addons/web/static/src/js/fields/basic_fields.js')
-rw-r--r--addons/web/static/src/js/fields/basic_fields.js7
1 files changed, 6 insertions, 1 deletions
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;