From 6c85d925c310fbbcd5b5f374932440b2e6482e37 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Mon, 4 Jul 2016 18:36:27 +0200 Subject: [FIX] web: dialog close with a reason In the below revision: c0db6aec56d383d173fa56b1a2dec2e42495911b The dialog close `reason` was introduced to not reload the current form if the dialog has been closed for a reason (e.g. a window action was returned by the server). This is to prevent the record reload, which: - Is useless, as another action has been launched and the user therefore redirected elsewhere - Can fail, in the case the initial action deleted the current record (e.g. when merging a lead in an opportunity, the lead is removed, and therefore this is not possible to reload it). opw-680180 --- addons/web/static/src/js/framework/dialog.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/framework/dialog.js b/addons/web/static/src/js/framework/dialog.js index cd4540af270..b39cae3c3a5 100644 --- a/addons/web/static/src/js/framework/dialog.js +++ b/addons/web/static/src/js/framework/dialog.js @@ -124,11 +124,11 @@ var Dialog = Widget.extend({ this.$modal.modal('hide'); }, - destroy: function() { + destroy: function(reason) { if(this.isDestroyed()) return; - this.trigger("closed"); + this.trigger("closed", reason); this._super(); -- cgit v1.2.3 From 489ea4285996662382a31c47bc33c6d7a3e9c80b Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Tue, 5 Jul 2016 17:49:10 +0200 Subject: [FIX] web: parsing of date with abbreviated month/day When using the abbreviated month in the language date format (`%b`), e.g. `%d %b %Y` in some languages, the parsing of the date from this format to the database format (YYYY-mm-dd) failed because of a dot `.` added from time to time to the end of the abbreviated name e.g., in French, `5 juil. 2016` This is a bug of `moment.js` < 2.13.0, handling badly this dot. This is solved from `moment.js` 2.13.0, thanks to the below revision moment/moment@41fdb58572546740c3a840ebd36fbe9e1bcdc9cb moment/moment#3078 Unfortunately, we cannot update this library to its latest release in stable release of Odoo (e.g. 9.0), as this is seen as an unstable change (if some API changes occured in the given library) Instead, if the parsing of the date fails with the strict mode (meaning the date must respect the format exactly), we perform a second pass without the strict mode, so this dot will be ignored, and the date can be correctly parsed. The issue can be reproduced by loading the French language, and setting `%d %b %Y` as date format, and then performing an advanced search on a date field. The value of the date in the advanced search will be empty without this revision (for the months having more than 4 chars, other than `mars`, `mai`, `juin`, `aout`). Fixes #11854 opw-682534 --- addons/web/static/src/js/framework/formats.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/framework/formats.js b/addons/web/static/src/js/framework/formats.js index 52a2fa5b0b0..8a5a8ffedb7 100644 --- a/addons/web/static/src/js/framework/formats.js +++ b/addons/web/static/src/js/framework/formats.js @@ -161,11 +161,17 @@ function parse_value (value, descriptor, value_if_empty) { return parse_value(value, {type: "float"}); case 'datetime': var datetime = moment(value, [date_pattern + ' ' + time_pattern, date_pattern_wo_zero + ' ' + time_pattern_wo_zero, moment.ISO_8601], true); + if (datetime.isValid()) + return time.datetime_to_str(datetime.toDate()); + datetime = moment(value, [date_pattern + ' ' + time_pattern, date_pattern_wo_zero + ' ' + time_pattern_wo_zero, moment.ISO_8601]); if (datetime.isValid()) return time.datetime_to_str(datetime.toDate()); throw new Error(_.str.sprintf(_t("'%s' is not a correct datetime"), value)); case 'date': var date = moment(value, [date_pattern, date_pattern_wo_zero, moment.ISO_8601], true); + if (date.isValid()) + return time.date_to_str(date.toDate()); + date = moment(value, [date_pattern, date_pattern_wo_zero, moment.ISO_8601]); if (date.isValid()) return time.date_to_str(date.toDate()); throw new Error(_.str.sprintf(_t("'%s' is not a correct date"), value)); -- cgit v1.2.3