summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2019-01-25 16:49:07 +0000
committerChristophe Simonis <chs@odoo.com>2019-01-25 17:29:34 +0000
commitc8ace043e50b202c88df81b9c02cc58256982d77 (patch)
treee0c3872843d7b77d5544ca526a8bd8037713fad0 /addons/web/static/src
parente8803e91e22ace82f2ff8712e5c81c8c68ad3930 (diff)
parent387d5cff90bdea935f6cd5b2b90f1125c5ea47a1 (diff)
[MERGE] forward port branch saas-11.3 up to 387d5cff90b
closes odoo/odoo#30566
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/fields/relational_fields.js6
-rw-r--r--addons/web/static/src/js/views/form/form_controller.js9
-rw-r--r--addons/web/static/src/js/views/form/form_renderer.js45
-rw-r--r--addons/web/static/src/xml/base.xml2
4 files changed, 45 insertions, 17 deletions
diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js
index 60b0275c8c8..ff9d6359dd1 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/form/form_controller.js b/addons/web/static/src/js/views/form/form_controller.js
index b7c8e8a6214..45b68ce6bea 100644
--- a/addons/web/static/src/js/views/form/form_controller.js
+++ b/addons/web/static/src/js/views/form/form_controller.js
@@ -228,17 +228,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 c7a32b72ba9..91146ccd504 100644
--- a/addons/web/static/src/js/views/form/form_renderer.js
+++ b/addons/web/static/src/js/views/form/form_renderer.js
@@ -13,6 +13,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, {
@@ -30,6 +31,7 @@ var FormRenderer = BasicRenderer.extend({
this._super.apply(this, arguments);
this.idsForLabels = {};
this.lastActivatedFieldIndex = -1;
+ this.alertFields = {};
},
/**
* @override
@@ -103,23 +105,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);
+ }
}
},
/**
@@ -905,6 +916,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(){
@@ -1015,6 +1029,15 @@ var FormRenderer = BasicRenderer.extend({
event.preventDefault();
this.trigger_up('translate', {fieldName: event.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/xml/base.xml b/addons/web/static/src/xml/base.xml
index 30f160460cd..5a416938362 100644
--- a/addons/web/static/src/xml/base.xml
+++ b/addons/web/static/src/xml/base.xml
@@ -1525,7 +1525,7 @@
<div role="alertdialog">
Please update translations of :
<t t-foreach="fields" t-as="field">
- <strong><a class="oe_field_translate" t-att-name="field.name" href="#"><t t-esc="field.string"/><t t-if="!field_last">, </t></a></strong>
+ <strong><a class="oe_field_translate" t-att-name="field" href="#"><t t-esc="field_value.string"/><t t-if="field_index &lt; _.size(fields)-1">, </t></a></strong>
</t>
</div>
</t>