Skip to content
Snippets Groups Projects
Commit 869c3ec7 authored by Hervé Silvant - CGScop's avatar Hervé Silvant - CGScop
Browse files

Ajout d'un total par activité sur l'impression de la feuille de temps

parent 0c0f7a76
No related branches found
No related tags found
1 merge request!9Ajout d'un total par activité sur l'impression de la feuille de temps
......@@ -123,3 +123,54 @@ class ScopHrTimesheetSheet(models.Model):
return self.env.ref(
"cgscop_timesheet.cgscop_timesheet_sheet_report"
).report_action(self)
# ------------------------------------------------------
# Retourne les lignes de la Fdt avec les totaux par projet
# ------------------------------------------------------
def _to_duration(self, infloat):
return '{0:02.0f}:{1:02.0f}'.format(*divmod(infloat * 60, 60))
def _get_timesheet_line_act(self):
for sheet in self:
lines = sheet.timesheet_line_ids.sorted(key=lambda b: (b.project_id.name, b.date))
rows = []
last_project = False
tot_project = 0
for line in lines:
# On insère un total intermédiaire
if last_project != line.project_id.name and tot_project != 0:
rows.append({
'total': 1,
'name': False,
'partner': False,
'project': False,
'date': False,
'ur_financial_system': 'Total ' + last_project + ' : ' + self._to_duration(tot_project),
'unit_amount': False,
})
tot_project = 0
# On insère la ligne lue
rows.append({
'total': 0,
'name': line.name,
'partner': line.partner_id.name,
'project': line.project_id.name,
'date': line.date,
'ur_financial_system': line.ur_financial_system_id.name,
'unit_amount': self._to_duration(line.unit_amount),
})
last_project = line.project_id.name
tot_project = tot_project + line.unit_amount
# On insère le dernier total
rows.append({
'total': 1,
'name': False,
'partner': False,
'project': False,
'date': False,
'ur_financial_system': 'Total ' + last_project + ' : ' + self._to_duration(tot_project),
'unit_amount': False,
})
return rows
......@@ -51,21 +51,27 @@
</thead>
<tbody class="invoice_tbody">
<t
t-foreach="o.timesheet_line_ids.sorted(key=lambda b: (b.project_id.name,b.date))"
t-foreach="o._get_timesheet_line_act()"
t-as="line"
>
<tr>
<td><span t-field="line.project_id" /></td>
<td><span t-field="line.date" /></td>
<td><span t-field="line.partner_id" /></td>
<td><span t-field="line.name" /></td>
<td><span
t-field="line.ur_financial_system_id"
/></td>
<td class="text-right"><span
t-field="line.unit_amount"
t-options="{'widget': 'duration', 'digital': True, 'unit': 'hour', 'round': 'minute'}"
/></td>
<td><span><t t-esc="line['project']"/></span></td>
<td><span><t t-esc="line['date']"/></span></td>
<td><span><t t-esc="line['partner']"/></span></td>
<td><span><t t-esc="line['name']"/></span></td>
<td><span>
<t t-if="line['total']==1">
<strong>
<t t-esc="line['ur_financial_system']"/>
</strong>
</t>
<t t-if="line['total']==0">
<t t-esc="line['ur_financial_system']"/>
</t>
</span></td>
<td class="text-right"><span>
<t t-esc="line['unit_amount']"/>
</span></td>
</tr>
</t>
<tr>
......
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