Skip to content

Commit

Permalink
[IMP] sale_timesheet: use float_time widget
Browse files Browse the repository at this point in the history
And clean the view
  • Loading branch information
mart-e committed Sep 29, 2017
1 parent 8f1e83e commit 5e7cbc6
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 25 deletions.
5 changes: 0 additions & 5 deletions addons/sale_timesheet/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,12 @@ def plan(self, domain):

def _prepare_plan_values(self, domain):

def float_to_time(hour_number):
hours, minutes = divmod(hour_number * 60, 60)
return _('%02d:%02d') % (hours, minutes)

timesheet_lines = request.env['account.analytic.line'].search(domain)

values = {
'currency': request.env.user.company_id.currency_id,
'timesheet_lines': timesheet_lines,
'domain': domain,
'float_to_time': float_to_time,
}
hour_rounding = request.env.ref('product.product_uom_hour').rounding
billable_types = ['non_billable', 'non_billable_project', 'billable_time', 'billable_fixed']
Expand Down
6 changes: 0 additions & 6 deletions addons/sale_timesheet/i18n/sale_timesheet.pot
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ msgid "\n"
" "
msgstr ""

#. module: sale_timesheet
#: code:addons/sale_timesheet/controllers/main.py:24
#, python-format
msgid "%sh%s"
msgstr ""

#. module: sale_timesheet
#: model:ir.ui.view,arch_db:sale_timesheet.timesheet_plan
msgid "<b>Total</b>"
Expand Down
59 changes: 45 additions & 14 deletions addons/sale_timesheet/views/hr_timesheet_templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<a type="action" t-att-domain="json.dumps(domain)" context="{'pivot_row_groupby': ['date:month'],'pivot_column_groupby': ['timesheet_invoice_type'], 'pivot_measures': ['unit_amount']}">Hours</a>
</th>
<td class="o_timesheet_plan_dashboard_cell">
<t t-esc="float_to_time(dashboard['hours']['billable_time'])"/>
<t t-esc="dashboard['hours']['billable_time']" t-options="{'widget': 'float_time'}"/>
</td>
<td>Time and material</td>
<th rowspan="5">
Expand All @@ -60,7 +60,7 @@
</tr>
<tr>
<td class="o_timesheet_plan_dashboard_cell">
<t t-esc="float_to_time(dashboard['hours']['billable_fixed'])"/>
<t t-esc="dashboard['hours']['billable_fixed']" t-options="{'widget': 'float_time'}"/>
</td>
<td>Fixed</td>
<td class="o_timesheet_plan_dashboard_cell">
Expand All @@ -76,7 +76,7 @@
</tr>
<tr>
<td class="o_timesheet_plan_dashboard_cell">
<t t-esc="float_to_time(dashboard['hours']['non_billable_project'])"/>
<t t-esc="dashboard['hours']['non_billable_project']" t-options="{'widget': 'float_time'}"/>
</td>
<td>No task found</td>
<td class="o_timesheet_plan_dashboard_cell">
Expand All @@ -92,7 +92,7 @@
</tr>
<tr>
<td class="o_timesheet_plan_dashboard_cell">
<t t-esc="float_to_time(dashboard['hours']['non_billable'])"/>
<t t-esc="dashboard['hours']['non_billable']" t-options="{'widget': 'float_time'}"/>
</td>
<td>Non Billable</td>
<td class="o_timesheet_plan_dashboard_cell">
Expand All @@ -104,7 +104,7 @@
</tr>
<tr>
<td class="o_timesheet_plan_dashboard_total">
<t t-esc="float_to_time(dashboard['hours']['total'])"/>
<t t-esc="dashboard['hours']['total']" t-options="{'widget': 'float_time'}"/>
</td>
<td><b>Total</b></td>
<td class="o_timesheet_plan_dashboard_total">
Expand Down Expand Up @@ -152,18 +152,49 @@
</a>
</td>
<td style="width: 10%">
<t t-esc="float_to_time(repartition_employee[employee_id]['total'])"/>
<t t-esc="repartition_employee[employee_id]['total']" t-options="{'widget': 'float_time'}"/>
</td>
<td>
<div class="progress" t-att-style="'width: ' + str(repartition_employee[employee_id]['total'] / repartition_employee_max * 100) +'%'">
<div t-if="repartition_employee[employee_id]['billable_fixed']" class="progress-bar o_progress_billable_fixed" t-att-style="'width: ' + str(repartition_employee[employee_id]['billable_fixed'] / repartition_employee[employee_id]['total'] * 100) + '%'" t-att-title="float_to_time(repartition_employee[employee_id]['billable_fixed'])" t-att-data-domain="repartition_employee[employee_id]['__domain_billable_fixed']">
</div>
<div t-if="repartition_employee[employee_id]['billable_time']" class="progress-bar o_progress_billable_time" t-att-style="'width: ' + str(repartition_employee[employee_id]['billable_time'] / repartition_employee[employee_id]['total'] * 100) + '%'" t-att-title="float_to_time(repartition_employee[employee_id]['billable_time'])" t-att-data-domain="repartition_employee[employee_id]['__domain_billable_time']">
</div>
<div t-if="repartition_employee[employee_id]['non_billable_project']" class="progress-bar o_progress_non_billable_project" t-att-style="'width: ' + str(repartition_employee[employee_id]['non_billable_project'] / repartition_employee[employee_id]['total'] * 100) + '%'" t-att-title="float_to_time(repartition_employee[employee_id]['non_billable_project'])" t-att-data-domain="repartition_employee[employee_id]['__domain_non_billable_project']">
</div>
<div t-if="repartition_employee[employee_id]['non_billable']" class="progress-bar o_progress_non_billable" t-att-style="'width: ' + str(repartition_employee[employee_id]['non_billable'] / repartition_employee[employee_id]['total'] * 100) + '%'" t-att-title="float_to_time(repartition_employee[employee_id]['non_billable'])" t-att-data-domain="json.dumps(repartition_employee[employee_id]['__domain_non_billable'])">
</div>

<t t-set="total" t-value="repartition_employee[employee_id]['total']" />
<t t-set="billable_fixed" t-value="repartition_employee[employee_id]['billable_fixed']" />
<t t-set="billable_time" t-value="repartition_employee[employee_id]['billable_time']" />
<t t-set="non_billable" t-value="repartition_employee[employee_id]['non_billable']" />
<t t-set="non_billable_project" t-value="repartition_employee[employee_id]['non_billable_project']"/>

<t t-if="billable_fixed">
<t t-set="billable_fixed_title"><t t-esc="billable_fixed" t-options="{'widget': 'float_time'}" /></t>
<div class="progress-bar o_progress_billable_fixed"
t-att-style="'width: ' + str(billable_fixed / total * 100) + '%'"
t-att-title="billable_fixed_title"
t-att-data-domain="repartition_employee[employee_id]['__domain_billable_fixed']">
</div>
</t>
<t t-if="billable_time">
<t t-set="billable_time_title"><t t-esc="billable_time" t-options="{'widget': 'float_time'}" /></t>
<div class="progress-bar o_progress_billable_time"
t-att-style="'width: ' + str(billable_time / total * 100) + '%'"
t-att-title="billable_time_title"
t-att-data-domain="repartition_employee[employee_id]['__domain_billable_time']">
</div>
</t>
<t t-if="non_billable_project">
<t t-set="non_billable_project_title"><t t-esc="non_billable_project" t-options="{'widget': 'float_time'}" /></t>
<div class="progress-bar o_progress_non_billable_project"
t-att-style="'width: ' + str(non_billable_project / total * 100) + '%'"
t-att-title="non_billable_project_title"
t-att-data-domain="repartition_employee[employee_id]['__domain_non_billable_project']">
</div>
</t>
<t t-if="non_billable">
<t t-set="non_billable_title"><t t-esc="non_billable" t-options="{'widget': 'float_time'}" /></t>
<div class="progress-bar o_progress_non_billable"
t-att-style="'width: ' + str(non_billable / total * 100) + '%'"
t-att-title="non_billable_title"
t-att-data-domain="json.dumps(repartition_employee[employee_id]['__domain_non_billable'])">
</div>
</t>
</div>
</td>
</tr>
Expand Down

0 comments on commit 5e7cbc6

Please sign in to comment.