Files
odoo_source/addons/hr/static/src/views/form_view.js
T
Kevin Baptiste 2551efa736 [FIX] hr: remove t-on-* from views arch
Remove the call to `t-on-click` in the arch of form/kanban views as it
crashes when the view is opened in studio.

Instead use a dedicated `<widget>`.

closes odoo/odoo#103820

X-original-commit: 2a213a150b4421ce4da32db754651cfc41adbef4
Signed-off-by: Kevin Baptiste <kba@odoo.com>
2022-10-24 16:12:36 +02:00

45 lines
1.3 KiB
JavaScript

/** @odoo-module */
import { registry } from '@web/core/registry';
import { formView } from '@web/views/form/form_view';
import { FormController } from '@web/views/form/form_controller';
import { FormRenderer } from '@web/views/form/form_renderer';
import { useArchiveEmployee } from '@hr/views/archive_employee_hook';
import { useOpenChat } from "@mail/views/open_chat_hook";
export class EmployeeFormController extends FormController {
setup() {
super.setup();
this.archiveEmployee = useArchiveEmployee();
}
getActionMenuItems() {
const menuItems = super.getActionMenuItems();
if (!this.archiveEnabled || !this.model.root.isActive) {
return menuItems;
}
const archiveAction = menuItems.other.find((item) => item.key === "archive");
if (archiveAction) {
archiveAction.callback = this.archiveEmployee.bind(this, this.model.root.resId);
}
return menuItems;
}
}
// TODO KBA: to remove in master
export class EmployeeFormRenderer extends FormRenderer {
setup() {
super.setup();
this.openChat = useOpenChat(this.props.record.resModel);
}
}
registry.category('views').add('hr_employee_form', {
...formView,
Controller: EmployeeFormController,
Renderer: EmployeeFormRenderer,
});