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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
|
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="assets_backend" name="sale timesheet assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<link rel="stylesheet" type="text/scss" href="/sale_timesheet/static/src/scss/sale_timesheet.scss"/>
<script type="text/javascript" src="/sale_timesheet/static/src/js/project_overview.js"></script>
<script type="text/javascript" src="/sale_timesheet/static/src/js/sale_project_kanban_controller.js"/>
</xpath>
</template>
<record id="timesheet_plan" model="ir.ui.view">
<field name="name">Timesheet Plan</field>
<field name="type">qweb</field>
<field name="model">project.project</field>
<field name="arch" type="xml">
<qweb js_class="project_overview">
<nav class="o_qweb_cp_buttons" t-if="actions">
<button t-foreach="actions" t-as="action"
type="action" class="btn btn-primary"
t-att-name="action['action_id']"
t-att-data-context="action.get('context')"
>
<t t-esc="action['label']"/>
</button>
</nav>
<div class="o_form_view o_form_readonly o_project_plan">
<div class="o_form_sheet_bg">
<div class="o_form_sheet o_timesheet_plan_content">
<div class="o_timesheet_plan_sale_timesheet">
<div class="o_timesheet_plan_sale_timesheet_dashboard">
<div class="o_timesheet_plan_stat_buttons oe_button_box o_not_full">
<t t-foreach="stat_buttons" t-as="stat_button">
<a class="btn oe_stat_button"
type="action"
t-att="stat_button['action']"
>
<div t-attf-class="fa fa-fw o_button_icon #{stat_button['icon']}" role="img" aria-label="Statistics" title="Statistics"></div>
<div class="o_field_widget o_stat_info o_readonly_modifier" t-att-title="stat_button['name']">
<t t-if="not isinstance(stat_button['name'], list)">
<span class="o_stat_value" t-if="'count' in stat_button">
<t t-esc="stat_button['count']"/>
</span>
<span class="o_stat_text">
<t t-esc="stat_button['name']"/>
</span>
</t>
<t t-if="isinstance(stat_button['name'], list)">
<div class="oe_inline">
<span class="o_stat_value mr-1">
<t t-esc="stat_button.get('count')"/>
</span>
<span class="o_stat_value">
<t t-esc="stat_button['name'][0]"/>
</span>
</div>
<span class="o_stat_text">
<t t-esc="stat_button['name'][1]"/>
</span>
</t>
</div>
</a>
</t>
</div>
<div class="o_title">
<h2 t-if="is_uom_day">Recorded Days and Profitability</h2>
<h2 t-else="">Recorded Hours and Profitability</h2>
</div>
<t t-set="display_cost" t-value="dashboard['profit']['expense_cost'] != 0.0"/>
<div class="o_profitability_wrapper">
<div class="o_profitability_section">
<div>
<table class="table">
<tbody>
<th>
<a type="action" data-model="account.analytic.line" t-att-data-domain="json.dumps(timesheet_domain)"
data-context='{"pivot_row_groupby": ["date:month"],"pivot_column_groupby": ["timesheet_invoice_type"], "pivot_measures": ["unit_amount"]}'
data-views='[[0, "pivot"], [0, "list"]]' tabindex="-1">
<span t-if="is_uom_day">Days recorded</span>
<span t-else="">Hours recorded</span>
</a>
</th>
<tr>
<td class="o_timesheet_plan_dashboard_cell">
<t t-if="is_uom_day" t-esc="dashboard['time']['billable_time']" t-options="{'widget': 'timesheet_uom'}"/>
<t t-else="" t-esc="dashboard['time']['billable_time']" t-options="{'widget': 'float_time'}"/>
</td>
<td class="o_timesheet_plan_dashboard_cell">
(<t t-esc="dashboard['rates']['billable_time']"/> %)
</td>
<td title="Includes the time logged into tasks for which you invoice based on timesheets on tasks.">
Billed on Timesheets
</td>
</tr>
<tr>
<td class="o_timesheet_plan_dashboard_cell">
<t t-if="is_uom_day" t-esc="dashboard['time']['billable_fixed']" t-options="{'widget': 'timesheet_uom'}"/>
<t t-else="" t-esc="dashboard['time']['billable_fixed']" t-options="{'widget': 'float_time'}"/>
</td>
<td class="o_timesheet_plan_dashboard_cell">
(<t t-esc="dashboard['rates']['billable_fixed']"/> %)
</td>
<td title="Includes the time logged into tasks for which you invoice based on ordered quantities or on milestones.">
Billed at a Fixed price
</td>
</tr>
<tr t-if="dashboard['time']['non_billable_project'] != 0">
<td class="o_timesheet_plan_dashboard_cell">
<t t-if="is_uom_day" t-esc="dashboard['time']['non_billable_project']" t-options="{'widget': 'timesheet_uom'}"/>
<t t-else="" t-esc="dashboard['time']['non_billable_project']" t-options="{'widget': 'float_time'}"/>
</td>
<td class="o_timesheet_plan_dashboard_cell">
(<t t-esc="dashboard['rates']['non_billable_project']"/> %)
</td>
<td title="Includes the time logged from the Timesheet module that is linked to a project, but not to a task.">
No task found
</td>
</tr>
<tr>
<td class="o_timesheet_plan_dashboard_cell">
<t t-if="is_uom_day" t-esc="dashboard['time']['non_billable']" t-options="{'widget': 'timesheet_uom'}"/>
<t t-else="" t-esc="dashboard['time']['non_billable']" t-options="{'widget': 'float_time'}"/>
</td>
<td class="o_timesheet_plan_dashboard_cell">
(<t t-esc="dashboard['rates']['non_billable']"/> %)
</td>
<td>
<a type="action"
data-model="project.task"
data-views='[[false, "list"], [false, "form"]]'
t-att-data-domain="json.dumps([['project_id', 'in', projects.ids], ['sale_line_id', '=', False]])"
>
<span class="btn-link"
style="font-weight:normal;"
title="Includes the time logged into a task which is not linked to any Sales Order.">
Non Billable Tasks
</span>
</a>
</td>
</tr>
<tr t-if="dashboard['time']['non_billable_timesheet'] > 0">
<td class="o_timesheet_plan_dashboard_cell">
<t t-if="is_uom_day" t-esc="dashboard['time']['non_billable_timesheet']" t-options="{'widget': 'timesheet_uom'}"/>
<t t-else="" t-esc="dashboard['time']['non_billable_timesheet']" t-options="{'widget': 'float_time'}"/>
</td>
<td class="o_timesheet_plan_dashboard_cell">
(<t t-esc="dashboard['rates']['non_billable_timesheet']"/> %)
</td>
<td>
<a type="action"
data-model="account.analytic.line"
data-views='[[false, "list"], [false, "form"]]'
t-att-data-domain="json.dumps(timesheet_domain + [('timesheet_invoice_type','=','non_billable_timesheet')])"
>
<span class="btn-link"
style="font-weight:normal;">
Non Billable Timesheets
</span>
</a>
</td>
</tr>
<tr t-if="dashboard['time']['canceled'] > 0">
<td class="o_timesheet_plan_dashboard_cell">
<t t-if="is_uom_day" t-esc="dashboard['time']['canceled']" t-options="{'widget': 'timesheet_uom'}"/>
<t t-else="" t-esc="dashboard['time']['canceled']" t-options="{'widget': 'float_time'}"/>
</td>
<td class="o_timesheet_plan_dashboard_cell">
(<t t-esc="dashboard['rates']['canceled']"/> %)
</td>
<td title="Includes the time logged into a task which is linked to a cancelled Sales Order.">
Cancelled
</td>
</tr>
<tr>
<td class="o_timesheet_plan_dashboard_total">
<b>
<t t-if="is_uom_day" t-esc="dashboard['time']['total']" t-options="{'widget': 'timesheet_uom'}"/>
<t t-else="" t-esc="dashboard['time']['total']" t-options="{'widget': 'float_time'}"/>
</b>
</td>
<td><b>Total</b></td>
<td></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="o_profitability_section">
<div>
<table class="table">
<tbody>
<th>
<a type="action" data-model="project.profitability.report" t-att-data-domain="json.dumps(profitability_domain)" data-context="{'group_by_no_leaf':1, 'group_by':[], 'sale_show_order_product_name': 1}" data-views='[[0, "pivot"], [0, "graph"]]' tabindex="-1">Profitability</a>
</th>
<tr>
<td class="o_timesheet_plan_dashboard_cell">
<t t-esc="dashboard['profit']['invoiced']" t-options='{"widget": "monetary", "display_currency": currency}'/>
</td>
<td title="Revenues linked to Timesheets already invoiced.">
Invoiced
</td>
</tr>
<tr>
<td class="o_timesheet_plan_dashboard_cell">
<t t-esc="dashboard['profit']['to_invoice']" t-options='{"widget": "monetary", "display_currency": currency}'/>
</td>
<td title="Revenues linked to Timesheets not yet invoiced.">
To invoice
</td>
</tr>
<tr t-if="dashboard['profit']['other_revenues'] > 0">
<td class="o_timesheet_plan_dashboard_cell">
<t t-esc="dashboard['profit']['other_revenues']" t-options='{"widget": "monetary", "display_currency": currency}'/>
</td>
<td title="All revenues that are not from timesheets and that are linked to the analytic account of the project.">Other Revenues</td>
</tr>
<tr>
<td class="o_timesheet_plan_dashboard_cell">
<t t-esc="dashboard['profit']['cost']" t-options='{"widget": "monetary", "display_currency": currency}'/>
</td>
<td title="This cost is based on the "Timesheet cost" set in the HR Settings of your employees.">
Timesheet costs
</td>
</tr>
<tr t-if="display_cost">
<td class="o_timesheet_plan_dashboard_cell">
<t t-esc="dashboard['profit']['expense_cost']" t-options='{"widget": "monetary", "display_currency": currency}'/>
</td>
<td title="Any cost linked to the Analytic Account of the Project.">
Other costs
</td>
</tr>
<tr t-if="display_cost & (dashboard['profit']['expense_amount_untaxed_invoiced'] != 0)">
<td class="o_timesheet_plan_dashboard_cell">
<t t-esc="dashboard['profit']['expense_amount_untaxed_invoiced']" t-options='{"widget": "monetary", "display_currency": currency}'/>
</td>
<td title="Costs from expenses that were reinvoiced to your customer (provided that the Analytic Account of the Project was set on the Expense).">
Re-invoiced costs
</td>
</tr>
<tr>
<td class="o_timesheet_plan_dashboard_total">
<b>
<t t-esc="dashboard['profit']['total']" t-options='{"widget": "monetary", "display_currency": currency}'/>
</b>
</td>
<td><b>Total</b></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="o_title">
<h2>Time by people</h2>
</div>
<div class="o_timesheet_plan_sale_timesheet_people_time">
<t t-if="not repartition_employee">
<p>There are no timesheets for now.</p>
</t>
<t t-if="repartition_employee">
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th></th>
<th>Employee</th>
<th t-if="is_uom_day" class="text-nowrap text-right pr-5">Days Spent</th>
<th t-else="" class="text-nowrap text-right pr-5">Hours Spent</th>
<td>
<div class="float-right o_timesheet_plan_badge">
<span class="badge badge-pill o_progress_billable_time">
<a type="action" data-model="account.analytic.line" t-att-data-domain="json.dumps(timesheet_domain + [('timesheet_invoice_type','=','billable_time')])" tabindex="-1">Billed on Timesheets</a>
</span>
<span class="badge badge-pill o_progress_billable_fixed">
<a type="action" data-model="account.analytic.line" t-att-data-domain="json.dumps(timesheet_domain + [('timesheet_invoice_type','=','billable_fixed')])" tabindex="-1">Billed at a Fixed price</a>
</span>
<span t-if="dashboard['time']['non_billable_project'] != 0" class="badge badge-pill o_progress_non_billable_project">
<a type="action" data-model="account.analytic.line" t-att-data-domain="json.dumps(timesheet_domain + [('timesheet_invoice_type','=','non_billable_project')])" tabindex="-1">No task found</a>
</span>
<span t-if="dashboard['time']['non_billable_timesheet'] != 0" class="badge badge-pill o_progress_non_billable_timesheet">
<a type="action" data-model="account.analytic.line" t-att-data-domain="json.dumps(timesheet_domain + [('timesheet_invoice_type','=','non_billable_timesheet')])" tabindex="-1">Non billable timesheets</a>
</span>
<span class="badge badge-pill o_progress_non_billable">
<a type="action" data-model="account.analytic.line" t-att-data-domain="json.dumps(timesheet_domain + [('timesheet_invoice_type','=','non_billable')])" tabindex="-1">Non billable tasks</a>
</span>
<!-- only show the canceled pill if there were timesheets on canceled so -->
<t t-if="sum([employee.get('canceled', 0.0) for employee in repartition_employee.values()]) > 0">
<span class="badge badge-pill o_progress_canceled">
<a type="action" data-model="account.analytic.line" t-att-data-domain="json.dumps(timesheet_domain + [('so_line.state', '=', 'cancel')])" tabindex="-1">Cancelled</a>
</span>
</t>
</div>
</td>
</tr>
</thead>
<tbody>
<t t-foreach="repartition_employee" t-as="employee_id">
<t t-set="employee" t-value="repartition_employee[employee_id]"/>
<tr>
<td style="width: 3%; vertical-align: middle;">
<img class="img rounded-circle mr-2 mb-2" t-attf-src="/web/image?model=hr.employee&field=image_128&id=#{employee['employee_id']}" t-att-title="employee['employee_name']" t-att-alt="employee['employee_name']" width="25" height="25"/>
</td>
<td style="width: 15%; vertical-align: middle;" >
<a type="action" data-model="account.analytic.line" t-att-data-domain="json.dumps(timesheet_domain)" t-att-data-context="json.dumps({'search_default_employee_id': employee_id})" data-views="[[0, "list"]]" tabindex="-1">
<t t-esc="employee['employee_name']"/>
</a>
</td>
<td class="text-right pr-5" style="width: 10%; vertical-align: middle;">
<t t-if="is_uom_day" t-esc="employee['total']" t-options="{'widget': 'timesheet_uom'}"/>
<t t-else="" t-esc="employee['total']" t-options="{'widget': 'float_time'}"/>
</td>
<td style="vertical-align:middle">
<div class="border rounded">
<div t-if="repartition_employee_max" class="progress" t-attf-style="width: {{max(0, employee['total'] / repartition_employee_max * 100)}}%; margin-bottom: 0em;">
<t t-set="total" t-value="employee['total'] or 1.0" />
<t t-call="sale_timesheet.progressbar">
<t t-set="label">Billed on Timesheets</t>
<t t-set="key" t-translation="off">billable_time</t>
</t>
<t t-call="sale_timesheet.progressbar">
<t t-set="label">Billed at a Fixed price</t>
<t t-set="key" t-translation="off">billable_fixed</t>
</t>
<t t-call="sale_timesheet.progressbar">
<t t-set="label">No task found</t>
<t t-set="key" t-translation="off">non_billable_project</t>
</t>
<t t-call="sale_timesheet.progressbar">
<t t-set="label">Non billable timesheets</t>
<t t-set="key" t-translation="off">non_billable_timesheet</t>
</t>
<t t-call="sale_timesheet.progressbar">
<t t-set="label">Non billable tasks</t>
<t t-set="key" t-translation="off">non_billable</t>
</t>
<t t-call="sale_timesheet.progressbar">
<t t-set="label">Cancelled</t>
<t t-set="key" t-translation="off">canceled</t>
</t>
</div>
</div>
</td>
</tr>
</t>
</tbody>
</table>
</div>
</t>
</div>
<div class="o_title">
<h2>Timesheets</h2>
</div>
<!-- NOTE: this template to display a table works whatever the length of the rows, as project_timesheet_forecast_sale extends the table to add forecasts -->
<div class="o_project_plan_project_timesheet_forecast">
<t t-if="timesheet_forecast_table and timesheet_forecast_table['rows']">
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th></th>
<th colspan="5" id="table_plan_title" class="o_right_bordered"><h3>Timesheets</h3></th>
<th colspan="2" id="table_plan_total"></th>
</tr>
<tr>
<t t-foreach="timesheet_forecast_table['header']" t-as="header_val">
<th t-att-class="'o_right_bordered' if header_val_index in [5,10] else ''">
<span t-att-title="header_val['tooltip']"><t t-esc="header_val['label']"/></span>
</th>
</t>
</tr>
</thead>
<tbody>
<t t-set="row_is_milestone" t-value="False"/>
<t t-set="current_order" t-value="False"/>
<t t-set="current_order_line" t-value="False"/>
<t t-foreach="timesheet_forecast_table['rows']" t-as="row">
<t t-set="row_type" t-value="row[0].get('type')"/>
<t t-if="row_type == 'sale_order_line'">
<t t-set="row_is_milestone" t-value="row[0].get('is_milestone')"/>
</t>
<t t-if="row_type == 'sale_order'">
<t t-set="current_order" t-value="False"/>
<t t-set="current_order_line" t-value="False"/>
</t>
<t t-if="row_type == 'sale_order_line'">
<t t-set="current_order_line" t-value="False"/>
</t>
<t t-set="foldable" t-value="row[0].get('has_children')"/>
<tr t-att-class="'o_timesheet_forecast_' + row_type + ' sale_order_' + str(current_order) + ' sale_order_line_' + str(current_order_line)"
t-att-style="'display: none;' if row_type not in ('sale_order', 'sale_order_line') else ''">
<t t-foreach="row" t-as="row_value">
<td t-att-class="'o_right_bordered' if row_value_index in [5,10] else '' + ' text-center' if row_value_index != 0 else ''">
<t t-if="row_value_index == 0">
<span t-if="foldable" t-att-class="('fa fa-caret-down' if row_type == 'sale_order' else 'fa fa-caret-right') + (' project_overview_foldable' if foldable else '')"
style="cursor: pointer;" t-att-data-model="row[0].get('res_model')" t-att-data-res-id="row[0].get('res_id')"/>
<t t-if="row_type == 'sale_order'">
<t t-if="env.user.has_group('sales_team.group_sale_salesman')">
<a type="action" t-att-data-model="row_value['res_model']" t-att-data-res-id="row_value['res_id']" t-att-class="'o_timesheet_plan_redirect' if row_value['res_id'] else ''">
<t t-esc="row_value.get('label')"/>
</a>
</t>
<t t-else="">
<t t-esc="row_value.get('label')"/>
</t>
<span t-if="row_value.get('canceled')" class="badge badge-pill o_canceled_tag">
Cancelled
</span>
</t>
<t t-if="row_type != 'sale_order'">
<t t-if="not row_is_milestone">
<span><t t-esc="row_value.get('label')"/></span>
</t>
<t t-if="row_is_milestone">
<span><i><t t-esc="row_value.get('label')"/></i></span>
</t>
</t>
</t>
<t t-if="row_value_index != 0">
<t t-if="row_value_index < len(row)-2">
<t t-if="row_is_milestone">
<i t-att-class="'text-muted' if not row_value else ''">
<t t-if="is_uom_day" t-esc="row_value" t-options="{'widget': 'timesheet_uom'}"/>
<t t-else="" t-esc="row_value" t-options="{'widget': 'float_time'}"/>
</i>
</t>
<t t-else="">
<span t-att-class="'text-muted' if not row_value else ''">
<t t-if="is_uom_day" t-esc="row_value" t-options="{'widget': 'timesheet_uom'}"/>
<t t-else="" t-esc="row_value" t-options="{'widget': 'float_time'}"/>
</span>
</t>
</t>
<t t-else="">
<t t-if="not row_is_milestone and not row[0].get('type') == 'hr_employee'">
<span t-att-class="'text-muted' if not row_value else ''">
<t t-if="is_uom_day" t-esc="row_value" t-options="{'widget': 'timesheet_uom'}"/>
<t t-else="" t-esc="row_value" t-options="{'widget': 'float_time'}"/>
</span>
</t>
</t>
</t>
</td>
</t>
</tr>
<t t-if="row_type == 'sale_order_line'">
<t t-set="current_order_line" t-value="row[0].get('res_id')"/>
</t>
<t t-if="row_type == 'sale_order'">
<t t-set="current_order" t-value="row[0].get('res_id')"/>
</t>
</t>
</tbody>
</table>
</div>
</t>
</div>
</div>
</div>
</div>
</div>
</qweb>
</field>
</record>
<template id="progressbar" name="project overview progressbar segments">
<t t-set="amount" t-value="employee[key]"/>
<t t-if="amount > 0">
<t t-set="title">
<t t-esc="label"/>: <t t-if="is_uom_day" t-esc="amount" t-options="{'widget': 'timesheet_uom'}"/><t t-else="" t-esc="amount" t-options="{'widget': 'float_time'}"/>
</t>
<a t-attf-class="progress-bar o_progress_{{key}}"
t-attf-style="width: {{amount / total * 100}}%"
type="action" data-model="account.analytic.line"
t-att-data-domain="employee['__domain_' + key]"
>
<span t-att-title="title" style="font-size: 0px; width: 100%; height: 100%;">
<t t-esc="label" />
</span>
</a>
</t>
</template>
</odoo>
|