[IMP] employee profile: Reload the view if language changed

When a user change his langage in employee profile, he doesn't see
the result before reloading manually the page.

With this commit, when a user change his language, the page is
reloaded on saving. And remove Create button on My Profile

closes odoo/odoo#34906

Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This commit is contained in:
jbm-odoo
2019-08-02 11:44:45 +00:00
committed by Yannick Tivisse
parent 0fe2b4530f
commit 252609d375
3 changed files with 29 additions and 1 deletions
+27
View File
@@ -0,0 +1,27 @@
odoo.define('hr.employee_language', function (require) {
'use strict';
var FormController = require('web.FormController');
var FormView = require('web.FormView');
var viewRegistry = require('web.view_registry');
var EmployeeFormController = FormController.extend({
saveRecord: function () {
var self = this;
return this._super.apply(this, arguments).then(function () {
if (arguments[0].indexOf('lang') >= 0) {
self.do_action('reload_context');
}
});
},
});
var EmployeeProfileFormView = FormView.extend({
config: _.extend({}, FormView.prototype.config, {
Controller: EmployeeFormController,
}),
});
viewRegistry.add('hr_employee_profile_form', EmployeeProfileFormView);
return EmployeeProfileFormView;
});
+1
View File
@@ -5,6 +5,7 @@
<xpath expr="." position="inside">
<link rel="stylesheet" type="text/scss" href="/hr/static/src/scss/hr.scss"/>
<script type="text/javascript" src="/hr/static/src/js/chat.js"></script>
<script type="text/javascript" src="/hr/static/src/js/language.js"></script>
</xpath>
</template>
</odoo>
+1 -1
View File
@@ -48,7 +48,7 @@
<field name="inherit_id" ref="res_users_view_form_simple_modif"/>
<field name="arch" type="xml">
<form position="replace">
<form>
<form create="false" js_class="hr_employee_profile_form">
<field name="hr_presence_state" invisible="1"/>
<header></header> <!-- Used by other modules to add buttons -->
<sheet>