diff options
| author | Christophe Simonis <chs@odoo.com> | 2019-01-31 16:59:58 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2019-01-31 16:59:58 +0100 |
| commit | f927c68ddbe4dccbdd0174019d6028d30b0d8058 (patch) | |
| tree | af24ebffe8241ee0c6ec9c911f2fe15f54237bcc /addons/web/static/src/js | |
| parent | 24ba5ae276a7c25cdcd4d2db2e17e032cfa7e52a (diff) | |
| parent | cb8fefa8999bd0056c2191edbdbbb85918d221da (diff) | |
[MERGE] forward port branch 12.0 up to cb8fefa8999
Diffstat (limited to 'addons/web/static/src/js')
9 files changed, 64 insertions, 23 deletions
diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js index 6d53d283f8a..14eb10c663c 100644 --- a/addons/web/static/src/js/fields/relational_fields.js +++ b/addons/web/static/src/js/fields/relational_fields.js @@ -240,6 +240,12 @@ var FieldMany2One = AbstractField.extend({ */ _bindAutoComplete: function () { var self = this; + // avoid ignoring autocomplete="off" by obfuscating placeholder, see #30439 + if (this.$input.attr('placeholder')) { + this.$input.attr('placeholder', function (index, val) { + return val.split('').join('\ufeff'); + }); + } this.$input.autocomplete({ source: function (req, resp) { _.each(self._autocompleteSources, function (source) { diff --git a/addons/web/static/src/js/views/basic/basic_model.js b/addons/web/static/src/js/views/basic/basic_model.js index 9706251ed07..646e883fb7e 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -432,6 +432,7 @@ var BasicModel = AbstractModel.extend({ var isNew = this.isNew(id); var rollback = 'rollback' in options ? options.rollback : isNew; var initialOffset = element.offset; + element._domains = {}; this._visitChildren(element, function (elem) { if (rollback && elem._savePoint) { if (elem._savePoint instanceof Array) { diff --git a/addons/web/static/src/js/views/calendar/calendar_renderer.js b/addons/web/static/src/js/views/calendar/calendar_renderer.js index c2c90ea7e62..03c59885fbe 100644 --- a/addons/web/static/src/js/views/calendar/calendar_renderer.js +++ b/addons/web/static/src/js/views/calendar/calendar_renderer.js @@ -362,6 +362,11 @@ return AbstractRenderer.extend({ this.$calendar = this.$(".o_calendar_widget"); + // This seems like a workaround but apparently passing the locale + // in the options is not enough. We should initialize it beforehand + var locale = moment.locale(); + $.fullCalendar.locale(locale); + //Documentation here : http://arshaw.com/fullcalendar/docs/ var fc_options = $.extend({}, this.state.fc_options, { eventDrop: function (event) { @@ -414,6 +419,7 @@ return AbstractRenderer.extend({ height: 'parent', unselectAuto: false, isRTL: _t.database.parameters.direction === "rtl", + locale: locale, // reset locale when fullcalendar has already been instanciated before now }); this.$calendar.fullCalendar(fc_options); diff --git a/addons/web/static/src/js/views/control_panel/search/search_filters.js b/addons/web/static/src/js/views/control_panel/search/search_filters.js index 6ff84dce9c7..4703995ac7c 100644 --- a/addons/web/static/src/js/views/control_panel/search/search_filters.js +++ b/addons/web/static/src/js/views/control_panel/search/search_filters.js @@ -193,8 +193,10 @@ var DateTime = Field.extend({ operators: [ {value: "=", text: _lt("is equal to")}, {value: "!=", text: _lt("is not equal to")}, - {value: ">=", text: _lt("is after")}, - {value: "<=", text: _lt("is before")}, + {value: ">", text: _lt("is after")}, + {value: "<", text: _lt("is before")}, + {value: ">=", text: _lt("is after or equal to")}, + {value: "<=", text: _lt("is before or equal to")}, {value: "between", text: _lt("is between")}, {value: "∃", text: _lt("is set")}, {value: "∄", text: _lt("is not set")} diff --git a/addons/web/static/src/js/views/form/form_controller.js b/addons/web/static/src/js/views/form/form_controller.js index 5feefce716f..d85a538d5ec 100644 --- a/addons/web/static/src/js/views/form/form_controller.js +++ b/addons/web/static/src/js/views/form/form_controller.js @@ -227,17 +227,16 @@ var FormController = BasicController.extend({ // are displayed with an alert var fields = self.renderer.state.fields; var data = self.renderer.state.data; - var alertFields = []; + var alertFields = {}; for (var k = 0; k < changedFields.length; k++) { var field = fields[changedFields[k]]; var fieldData = data[changedFields[k]]; if (field.translate && fieldData) { - alertFields.push(field); + alertFields[changedFields[k]] = field; } } - if (alertFields.length) { - self.renderer.alertFields = alertFields; - self.renderer.displayTranslationAlert(); + if (!_.isEmpty(alertFields)) { + self.renderer.updateAlertFields(alertFields); } } return changedFields; diff --git a/addons/web/static/src/js/views/form/form_renderer.js b/addons/web/static/src/js/views/form/form_renderer.js index 52bbc044d1f..2d6615b4b00 100644 --- a/addons/web/static/src/js/views/form/form_renderer.js +++ b/addons/web/static/src/js/views/form/form_renderer.js @@ -14,6 +14,7 @@ var FormRenderer = BasicRenderer.extend({ className: "o_form_view", events: _.extend({}, BasicRenderer.prototype.events, { 'click .o_notification_box .oe_field_translate': '_onTranslate', + 'click .o_notification_box .close': '_onTranslateNotificationClose', 'click .oe_title, .o_inner_group': '_onClick', }), custom_events: _.extend({}, BasicRenderer.prototype.custom_events, { @@ -31,6 +32,7 @@ var FormRenderer = BasicRenderer.extend({ this._super.apply(this, arguments); this.idsForLabels = {}; this.lastActivatedFieldIndex = -1; + this.alertFields = {}; }, /** * @override @@ -104,23 +106,32 @@ var FormRenderer = BasicRenderer.extend({ }); return fieldNames; }, + /* + * Updates translation alert fields for the current state and display updated fields + * + * @param {Object} alertFields + */ + updateAlertFields: function (alertFields) { + this.alertFields[this.state.res_id] = _.extend(this.alertFields[this.state.res_id] || {}, alertFields); + this.displayTranslationAlert(); + }, /** * Show a warning message if the user modified a translated field. For each * field, the notification provides a link to edit the field's translations. - * - * @param {Object[]} alertFields field list */ displayTranslationAlert: function () { this.$('.o_notification_box').remove(); - var $notification = $(qweb.render('notification-box', {type: 'info'})) - .append(qweb.render('translation-alert', { - fields: this.alertFields, - lang: _t.database.parameters.name - })); - if (this.$('.o_form_statusbar').length) { - this.$('.o_form_statusbar').after($notification); - } else { - this.$el.prepend($notification); + if (this.alertFields[this.state.res_id]) { + var $notification = $(qweb.render('notification-box', {type: 'info'})) + .append(qweb.render('translation-alert', { + fields: this.alertFields[this.state.res_id], + lang: _t.database.parameters.name + })); + if (this.$('.o_form_statusbar').length) { + this.$('.o_form_statusbar').after($notification); + } else { + this.$el.prepend($notification); + } } }, /** @@ -334,6 +345,7 @@ var FormRenderer = BasicRenderer.extend({ }); self.trigger_up('swipe_right'); }, + excludedElements: ".o_notebook .nav.nav-tabs", }); }, /** @@ -915,6 +927,9 @@ var FormRenderer = BasicRenderer.extend({ return $.when.apply($, defs).then(function () { self._updateView($form.contents()); + if (self.state.res_id in self.alertFields) { + self.displayTranslationAlert(); + } }, function () { $form.remove(); }).then(function(){ @@ -1030,6 +1045,15 @@ var FormRenderer = BasicRenderer.extend({ ev.preventDefault(); this.trigger_up('translate', {fieldName: ev.target.name, id: this.state.id}); }, + /** + * remove alert fields of record from alertFields object + * + * @private + * @param {MouseEvent} ev + */ + _onTranslateNotificationClose: function(ev) { + delete this.alertFields[this.state.res_id]; + }, }); return FormRenderer; diff --git a/addons/web/static/src/js/views/graph/graph_renderer.js b/addons/web/static/src/js/views/graph/graph_renderer.js index 856882a303b..09706695bbc 100644 --- a/addons/web/static/src/js/views/graph/graph_renderer.js +++ b/addons/web/static/src/js/views/graph/graph_renderer.js @@ -198,10 +198,12 @@ return AbstractRenderer.extend({ } } - // For Bar chart View, we keep only groups where count > 0 - data[0].values = _.filter(data[0].values, function (elem, index) { - return self.state.data[index].count > 0; - }); + // For one level Bar chart View, we keep only groups where count > 0 + if (this.state.groupedBy.length <= 1) { + data[0].values = _.filter(data[0].values, function (elem, index) { + return self.state.data[index].count > 0; + }); + } var $svgContainer = $('<div/>', {class: 'o_graph_svg_container'}); this.$el.append($svgContainer); diff --git a/addons/web/static/src/js/widgets/data_export.js b/addons/web/static/src/js/widgets/data_export.js index d05bf2d33fc..347769b4042 100644 --- a/addons/web/static/src/js/widgets/data_export.js +++ b/addons/web/static/src/js/widgets/data_export.js @@ -311,7 +311,7 @@ var DataExport = Dialog.extend({ }); self.$export_format_inputs = $fmts.find('input'); - self.$export_format_inputs.first().prop('checked', true); + self.$export_format_inputs.filter(':enabled').first().prop('checked', true); } }, show_exports_list: function() { diff --git a/addons/web/static/src/js/widgets/date_picker.js b/addons/web/static/src/js/widgets/date_picker.js index b677abe377a..367ab23178d 100644 --- a/addons/web/static/src/js/widgets/date_picker.js +++ b/addons/web/static/src/js/widgets/date_picker.js @@ -25,6 +25,7 @@ var DateWidget = Widget.extend({ this.name = parent.name; this.options = _.extend({ + locale: moment.locale(), format : this.type_of_date === 'datetime' ? time.getLangDatetimeFormat() : time.getLangDateFormat(), minDate: moment({ y: 1900 }), maxDate: moment().add(200, "y"), |
