Debian Codegraph @

addons/hr_timesheet/static/src/views/graph_model_patch.js

raw
1 import { user } from "@web/core/user";
2 import { patch } from "@web/core/utils/patch";
3
4 const FIELDS = [
5 'unit_amount', 'effective_hours', 'allocated_hours', 'remaining_hours', 'total_hours_spent', 'subtask_effective_hours',
6 'overtime', 'number_hours', 'difference', 'timesheet_unit_amount'
7 ];
8
9 export function patchGraphModel(Model) {
10 patch(Model.prototype, {
11 /**
12 * Override processDataPoints to take into account the analytic line uom.
13 * @override
14 */
15 _getProcessedDataPoints() {
16 const factor = user.activeCompany.timesheet_uom_factor || 1;
17 if (factor !== 1 && FIELDS.includes(this.metaData.measure)) {
18 // recalculate the Duration values according to the timesheet_uom_factor
19 for (const dataPt of this.dataPoints) {
20 dataPt.value *= factor;
21 }
22 }
23 return super._getProcessedDataPoints(...arguments);
24 }
25 });
26 }