summaryrefslogtreecommitdiff
path: root/addons/hr_timesheet/report/report_timesheet_templates.xml
blob: 1e74abaeecb7a7b3e974650baadcc011bc1ee7c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<odoo>
    <template id="report_timesheet">
        <t t-call="web.html_container">
            <t t-call="web.external_layout">
                <t t-set="company" t-value="docs.mapped('project_id')[0].company_id if len(docs.mapped('project_id')) == 1 else docs.env.company"/>
                <t t-set="show_task" t-value="bool(docs.mapped('task_id'))"/>
                <t t-set="show_project" t-value="len(docs.mapped('project_id')) > 1"/>
                <div class="page">
                    <div class="oe_structure"/>
                    <div class="row" style="margin-top:10px;">
                        <div class="col-lg-12">
                            <h2>
                                <span>Timesheet Entries
                                    <t t-if="len(docs.mapped('project_id')) == 1">
                                        for the <t t-esc="docs.mapped('project_id')[0].name"/> Project
                                    </t>
                                </span>
                            </h2>
                        </div>
                    </div>

                    <div class="row" style="margin-top:10px;">
                        <div class="col-lg-12">
                            <t t-set='is_uom_day' t-value='docs._is_timesheet_encode_uom_day()'/>
                            <table class="table table-sm">
                                <thead>
                                    <tr>
                                        <th class="align-middle"><span>Date</span></th>
                                        <th class="align-middle"><span>Responsible</span></th>
                                        <th class="align-middle"><span>Description</span></th>
                                        <th class="align-middle" t-if="show_project"><span>Project</span></th>
                                        <th class="align-middle" t-if="show_task"><span>Task</span></th>
                                        <th class="text-right">
                                            <span t-if="is_uom_day">Time Spent (Days)</span>
                                            <span t-else="">Time Spent (Hours)</span>
                                        </th>
                                    </tr>
                               </thead>
                               <tbody>
                                    <tr t-foreach="docs" t-as="l">
                                        <td>
                                           <span t-field="l.date"/>
                                        </td>
                                        <td>
                                           <span t-field="l.user_id.partner_id.name"/>
                                           <span t-if="not l.user_id.partner_id.name" t-field="l.employee_id"/>
                                        </td>
                                        <td >
                                            <span t-field="l.name" t-options="{'widget': 'text'}"/>
                                        </td>
                                        <td t-if="show_project">
                                            <span t-field="l.project_id.sudo().name"/>
                                        </td>
                                        <td t-if="show_task">
                                            <t t-if="l.task_id"><span t-field="l.task_id.sudo().name"/></t>
                                        </td>
                                        <td class="text-right">
                                            <span t-if="is_uom_day" t-esc="l._get_timesheet_time_day()" t-options="{'widget': 'timesheet_uom'}"/>
                                            <span t-else="" t-field="l.unit_amount" t-options="{'widget': 'duration', 'digital': True, 'unit': 'hour', 'round': 'minute'}"/>
                                        </td>
                                    </tr>
                                    <tr>
                                        <t t-set="nbCols" t-value="4"/>
                                        <t t-if="show_project" t-set="nbCols" t-value="nbCols + 1"/>
                                        <t t-if="show_task" t-set="nbCols" t-value="nbCols + 1"/>
                                        <td class="text-right" t-attf-colspan="{{nbCols}}">
                                            <strong t-if="is_uom_day">
                                                <span style="margin-right: 15px;">Total (Days)</span>
                                                <t t-esc="docs._convert_hours_to_days(sum(docs.mapped('unit_amount')))" t-options="{'widget': 'timesheet_uom'}"/>
                                            </strong>
                                            <strong t-else="">
                                                <span style="margin-right: 15px;">Total (Hours)</span>
                                                <t t-esc="sum(docs.mapped('unit_amount'))" t-options="{'widget': 'duration', 'digital': True, 'unit': 'hour', 'round': 'minute'}"/>
                                            </strong>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div class="oe_structure"/>
                </div>
            </t>
        </t>
    </template>

    <record id="timesheet_report" model="ir.actions.report">
        <field name="name">Timesheet Entries</field>
        <field name="model">account.analytic.line</field>
        <field name="report_type">qweb-pdf</field>
        <field name="report_name">hr_timesheet.report_timesheet</field>
        <field name="report_file">report_timesheet</field>
        <field name="binding_model_id" ref="model_account_analytic_line"/>
        <field name="binding_type">report</field>
    </record>
</odoo>