diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 701dc6824a1..5ac9d26eb98 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -648,8 +648,8 @@ class WebClient(http.Controller): ids = res_lang.search(request.cr, uid, [("code", "=", lang)]) lang_params = None if ids: - lang_params = res_lang.read(request.cr, uid, ids[0], ["direction", "date_format", "time_format", - "grouping", "decimal_point", "thousands_sep"]) + lang_params = res_lang.read(request.cr, uid, ids[0], + ["name", "direction", "date_format", "time_format", "grouping", "decimal_point", "thousands_sep"]) # Regional languages (ll_CC) must inherit/override their parent lang (ll), but this is # done server-side when the language is loaded, so we only need to load the user's lang. diff --git a/addons/web/static/src/js/views/form_view.js b/addons/web/static/src/js/views/form_view.js index 9720ed14a8c..e6b2390c35d 100644 --- a/addons/web/static/src/js/views/form_view.js +++ b/addons/web/static/src/js/views/form_view.js @@ -905,6 +905,7 @@ var FormView = View.extend(common.FieldManagerMixin, { if (!self.datarecord.id) { // Creation save save_deferral = self.dataset.create(values, {readonly_fields: readonly_values}).then(function(r) { + self.display_translation_alert(values); return self.record_created(r, prepend_on_create); }, null); } else if (_.isEmpty(values)) { @@ -913,6 +914,7 @@ var FormView = View.extend(common.FieldManagerMixin, { } else { // Write save save_deferral = self.dataset.write(self.datarecord.id, values, {readonly_fields: readonly_values}).then(function(r) { + self.display_translation_alert(values); return self.record_saved(r); }, null); } @@ -1072,6 +1074,32 @@ var FormView = View.extend(common.FieldManagerMixin, { sidebar_eval_context: function () { return $.when(this.build_eval_context()); }, + /* + * 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. + */ + display_translation_alert: function(values) { + if (_t.database.multi_lang) { + var alert_fields = _.filter(this.translatable_fields, function(field) { + return _.has(values, field.name) + }); + if (alert_fields.length) { + var $content = $(QWeb.render('translation-alert', { + fields: alert_fields, + lang: _t.database.parameters.name + })); + // bind click event on "Update translations" links + $content.find('.oe_field_translate').click(function(ev) { + ev.preventDefault(); + _.find(alert_fields, {'name': ev.target.name}).on_translate(); + }); + // show notification + this.once('to_view_mode', this, function () { + this.notify_in_form($content); + }); + } + } + }, /** * Add a notification box inside the form. The notification automatically * goes away (by default when switching to edit mode or changing the form diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 4ad7312d40c..fa9dadc0c72 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -1464,4 +1464,13 @@ + + +
+ You have updated (). + Update translations +
+
+
+