From 8bc68573bdb2e4ead428afc3293b053fd2bdc3b4 Mon Sep 17 00:00:00 2001 From: Jorge Pinna Puissant Date: Thu, 6 Oct 2022 11:00:54 +0000 Subject: [PATCH] [FIX] hr: reload_context when modifying the profile language Before this commit, only when using the save button on the profile, the context is reloaded with the new language. If we use the breadcrumb to exit the profile view, the new language is saved, but the context is not reloaded. closes odoo/odoo#102493 X-original-commit: 41b2ca93f1fc6402ff5d88b7dd8af175dd49ac6d Related: odoo/enterprise#32432 Signed-off-by: Aaron Bohy (aab) --- .../hr/static/src/views/profile_form_view.js | 34 ++++++++----------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/addons/hr/static/src/views/profile_form_view.js b/addons/hr/static/src/views/profile_form_view.js index d4caf92af17..93e30a641ca 100644 --- a/addons/hr/static/src/views/profile_form_view.js +++ b/addons/hr/static/src/views/profile_form_view.js @@ -1,29 +1,25 @@ /** @odoo-module */ -import { registry } from '@web/core/registry'; -import { useService } from "@web/core/utils/hooks"; +import { registry } from "@web/core/registry"; -import { formView } from '@web/views/form/form_view'; -import { FormController } from '@web/views/form/form_controller'; +import { formView } from "@web/views/form/form_view"; +import { Record, RelationalModel } from "@web/views/basic_relational_model"; - -export class EmployeeProfileFormController extends FormController { - setup() { - super.setup(); - this.action = useService('action'); - } - - async save(params = {}) { - const dirtyFields = this.model.root.dirtyFields.map((f) => f.name); - super.save(params); - - if (dirtyFields.includes('lang')) { - this.action.doAction("reload_context"); +export class EmployeeProfileRecord extends Record { + async save() { + const dirtyFields = this.dirtyFields.map((f) => f.name); + const res = await super.save(...arguments); + if (dirtyFields.includes("lang")) { + this.model.actionService.doAction("reload_context"); } + return res; } } -registry.category('views').add('hr_employee_profile_form', { +class EmployeeProfileModel extends RelationalModel {} +EmployeeProfileModel.Record = EmployeeProfileRecord; + +registry.category("views").add("hr_employee_profile_form", { ...formView, - Controller: EmployeeProfileFormController, + Model: EmployeeProfileModel, });