Skip to content
Snippets Groups Projects
Commit 2908dce3 authored by William Braeckman's avatar William Braeckman
Browse files

[IMP] hr_attendance: make use of new pivot/graph feature


Changes the previous attendance report override to use the new function
instead.

TaskId-2764844

closes odoo/odoo#85404

Related: odoo/enterprise#24765
Signed-off-by: default avatarKevin Baptiste <kba@odoo.com>
parent 54333236
No related branches found
No related tags found
No related merge requests found
......@@ -35,7 +35,7 @@ actions(Check in/Check out) performed by them.
'application': True,
'assets': {
'web.assets_backend': [
'hr_attendance/static/src/js/attendance_report_pivot_view.js',
'hr_attendance/static/src/js/attendance_report_views.js',
'hr_attendance/static/src/js/employee_kanban_view_handler.js',
'hr_attendance/static/src/js/greeting_message.js',
'hr_attendance/static/src/js/kiosk_mode.js',
......
......@@ -33,7 +33,7 @@
<field name="name">hr.attendance.report.view.graph</field>
<field name="model">hr.attendance.report</field>
<field name="arch" type="xml">
<graph string="Attendance Statistics" stacked="0" disable_linking="1">
<graph string="Attendance Statistics" stacked="0" js_class="attendance_report_graph">
<field name="employee_id"/>
<field name="check_in"/>
<field name="overtime_hours" type="measure" />
......
/** @odoo-module **/
import { registry } from "@web/core/registry";
import { PivotView } from "@web/views/pivot/pivot_view";
const viewRegistry = registry.category("views");
export class AttendanceReportPivotView extends PivotView {
/**
* @override
*/
onOpenView(cell) {
if (cell.value === undefined || this.model.metaData.disableLinking) {
return;
}
const context = Object.assign({}, this.model.searchParams.context);
Object.keys(context).forEach((x) => {
if (x === "group_by" || x.startsWith("search_default_")) {
delete context[x];
}
});
const group = {
rowValues: cell.groupId[0],
colValues: cell.groupId[1],
originIndex: cell.originIndexes[0],
};
const domain = this.model.getGroupDomain(group);
this.actionService.doAction({
type: "ir.actions.act_window",
name: this.model.metaData.title,
res_model: 'hr.attendance',
views: [[false, "list"], [false, "form"]],
view_mode: "list",
target: "current",
context,
domain,
});
}
}
viewRegistry.add("attendance_report_pivot", AttendanceReportPivotView);
/** @odoo-module **/
import { registry } from "@web/core/registry";
import { GraphView } from "@web/views/graph/graph_view";
import { PivotView } from "@web/views/pivot/pivot_view";
const viewRegistry = registry.category("views");
/**
* Open the hr.attendance instead of the report list view.
*/
function openView(component, domain, views, context) {
component.actionService.doAction({
type: "ir.actions.act_window",
name: component.model.metaData.title,
res_model: 'hr.attendance',
views: [[false, "list"], [false, "form"]],
view_mode: "list",
target: "current",
context,
domain,
});
}
export class AttendanceReportGraphView extends GraphView {
/**
* @override
*/
openView(domain, views, context) {
openView(this, domain, views, context);
}
}
viewRegistry.add("attendance_report_graph", AttendanceReportGraphView);
export class AttendanceReportPivotView extends PivotView {
/**
* @override
*/
openView(domain, views, context) {
openView(this, domain, views, context);
}
}
viewRegistry.add("attendance_report_pivot", AttendanceReportPivotView);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment