Skip to content

Commit 1a029ae

Browse files
romaincarlier4tivisse
authored andcommitted
[IMP] hr_holidays: add time off dashboard in kanban
When coming from the time off smartbutton on the employee, having a small banner indicating the number of leaves remaining is useful. This commit adds this banner, the same as in the time off dashboard. task-4860260 X-original-commit: c3f30ee Part-of: odoo#216690 Signed-off-by: Yannick Tivisse (yti) <[email protected]>
1 parent 200cb0d commit 1a029ae

File tree

6 files changed

+58
-2
lines changed

6 files changed

+58
-2
lines changed

addons/hr_holidays/models/hr_employee.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,11 @@ def _get_user_m2o_to_empty_on_archived_employees(self):
270270
def action_time_off_dashboard(self):
271271
action = self.env['ir.actions.act_window']._for_xml_id('hr_holidays.hr_leave_action_action_approve_department')
272272
action['context'] = dict(literal_eval(action['context']))
273-
action['context']['search_default_employee_id'] = self.ids
273+
action['context']['show_dashboard'] = True
274274
action['context'].pop('search_default_waiting_for_me', False)
275275
action['context'].pop('search_default_waiting_for_me_manager', False)
276+
action['context']['default_employee_id'] = self.id
277+
action['domain'] = [('employee_id', 'in', self.ids)]
276278
return action
277279

278280
def _is_leave_user(self):
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { KanbanController } from "@web/views/kanban/kanban_controller";
2+
import { EventBus, useSubEnv } from "@odoo/owl";
3+
4+
export class TimeOffKanbanController extends KanbanController {
5+
setup() {
6+
super.setup();
7+
useSubEnv({
8+
timeOffBus: new EventBus(),
9+
});
10+
}
11+
12+
afterExecuteActionButton(clickParams) {
13+
super.afterExecuteActionButton(clickParams);
14+
this.env.timeOffBus.trigger("update_dashboard");
15+
}
16+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { KanbanRenderer } from '@web/views/kanban/kanban_renderer';
2+
import { TimeOffDashboard } from '../../dashboard/time_off_dashboard';
3+
4+
export class TimeOffKanbanRenderer extends KanbanRenderer {
5+
static template = "hr_holidays.KanbanRenderer";
6+
static components = {
7+
...TimeOffKanbanRenderer.components,
8+
TimeOffDashboard,
9+
};
10+
get employeeId() {
11+
return this.env.model.config.context.active_id || null;
12+
}
13+
14+
get showDashboard() {
15+
return this.env.model.config.context.show_dashboard || false;
16+
}
17+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<templates xml:space="preserve">
3+
<t t-name="hr_holidays.KanbanRenderer">
4+
<div class="o_timeoff_calendar d-flex flex-column">
5+
<TimeOffDashboard t-if="showDashboard" employeeId="employeeId"/>
6+
<t t-call="web.KanbanRenderer"/>
7+
</div>
8+
</t>
9+
</templates>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { kanbanView } from '@web/views/kanban/kanban_view';
2+
import { registry } from '@web/core/registry';
3+
import { TimeOffKanbanRenderer } from './kanban_renderer';
4+
import { TimeOffKanbanController } from './kanban_controller';
5+
6+
const TimeOffKanbanView = {
7+
...kanbanView,
8+
Renderer: TimeOffKanbanRenderer,
9+
Controller: TimeOffKanbanController
10+
}
11+
12+
registry.category('views').add('time_off_kanban_dashboard', TimeOffKanbanView);

addons/hr_holidays/views/hr_leave_views.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
<field name="name">hr.leave.view.kanban</field>
9292
<field name="model">hr.leave</field>
9393
<field name="arch" type="xml">
94-
<kanban sample="1" class="o_holidays_view_kanban">
94+
<kanban sample="1" class="o_holidays_view_kanban" js_class="time_off_kanban_dashboard">
9595
<header>
9696
<button type="action"
9797
name="%(hr_holidays.action_hr_leave_generate_multi_wizard)d"

0 commit comments

Comments
 (0)