diff options
Diffstat (limited to 'addons/web/static/src/js/fields')
| -rw-r--r-- | addons/web/static/src/js/fields/basic_fields.js | 14 | ||||
| -rw-r--r-- | addons/web/static/src/js/fields/field_utils.js | 15 |
2 files changed, 17 insertions, 12 deletions
diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index 1b0e3a6c8a3..de5f80b0e92 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -1233,7 +1233,7 @@ var FieldBinaryFile = AbstractFieldBinary.extend({ template: 'FieldBinaryFile', events: _.extend({}, AbstractFieldBinary.prototype.events, { 'click': function (event) { - if (this.mode === 'readonly' && this.value) { + if (this.mode === 'readonly' && this.value && this.recordData.id) { this.on_save_as(event); } }, @@ -1250,10 +1250,20 @@ var FieldBinaryFile = AbstractFieldBinary.extend({ this.do_toggle(!!this.value); if (this.value) { this.$el.empty().append($("<span/>").addClass('fa fa-download')); + if (this.recordData.id) { + this.$el.css('cursor', 'pointer'); + } else { + this.$el.css('cursor', 'not-allowed'); + } if (this.filename_value) { 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) { @@ -1278,7 +1288,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; 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; |
