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') 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 From 6cc5a9963b3cce5d6ddf2cd038def5fe21f17af7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20Ku=CC=88hn?= Date: Mon, 4 Dec 2017 11:01:36 +0100 Subject: [FIX] web,*: time format from user's language Before this fix, the chatter always showed dates of messages in military time format. This was not the expected behavior, as the user could have had customize the date and time format in the settings of the current language. Steps to reproduce the issue: 1. Set Odoo in English 2. Settings > Translations > Languages > English 2.1. Set Date Format to %m/%d/%Y 2.2. Set Time Format to %I:%M:%S %p 3. CRM > (Select any opportunity with at least one message) > Mouse hover on elapsed time (e.g. "an hour ago") Expected: - It shows the customized time format (e.g. 11/07/2017 5:33:36 PM) Results: - It shows the military time format (e.g. Tue Nov 07 2017 17:33:36 GMT+0100) opw-781647 --- addons/web/static/src/js/fields/field_utils.js | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'addons/web/static/src/js/fields') diff --git a/addons/web/static/src/js/fields/field_utils.js b/addons/web/static/src/js/fields/field_utils.js index 7ba4122cccb..bca74acc088 100644 --- a/addons/web/static/src/js/fields/field_utils.js +++ b/addons/web/static/src/js/fields/field_utils.js @@ -97,8 +97,7 @@ function formatDate(value, field, options) { value = value.clone().add(session.getTZOffset(value), 'minutes'); } } - var l10n = core._t.database.parameters; - var date_format = time.strftime_to_moment_format(l10n.date_format); + var date_format = time.getLangDateFormat(); return value.format(date_format); } @@ -122,11 +121,7 @@ function formatDateTime(value, field, options) { if (!options || !('timezone' in options) || options.timezone) { value = value.clone().add(session.getTZOffset(value), 'minutes'); } - var l10n = core._t.database.parameters; - var date_format = time.strftime_to_moment_format(l10n.date_format); - var time_format = time.strftime_to_moment_format(l10n.time_format); - var datetime_format = date_format + ' ' + time_format; - return value.format(datetime_format); + return value.format(time.getLangDatetimeFormat()); } /** @@ -349,7 +344,7 @@ function parseDate(value, field, options) { if (!value) { return false; } - var datePattern = time.strftime_to_moment_format(core._t.database.parameters.date_format); + var datePattern = time.getLangDateFormat(); var datePatternWoZero = datePattern.replace('MM','M').replace('DD','D'); var date; if (options && options.isUTC) { @@ -388,8 +383,8 @@ function parseDateTime(value, field, options) { if (!value) { return false; } - var datePattern = time.strftime_to_moment_format(core._t.database.parameters.date_format), - timePattern = time.strftime_to_moment_format(core._t.database.parameters.time_format); + var datePattern = time.getLangDateFormat(), + timePattern = time.getLangTimeFormat(); var datePatternWoZero = datePattern.replace('MM','M').replace('DD','D'), timePatternWoZero = timePattern.replace('HH','H').replace('mm','m').replace('ss','s'); var pattern1 = datePattern + ' ' + timePattern; -- cgit v1.2.3