[MIG] project_working_time_task_portal: migrate to 18.0

This commit is contained in:
Stéphan Sainléger
2026-03-13 17:33:14 +01:00
parent e0b2a07b01
commit cdf8d6c320
13 changed files with 1390 additions and 0 deletions

View File

@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<template
id="portal_my_task_allocated_hours"
name="My Task: planned hours"
inherit_id="hr_timesheet.portal_my_task"
priority="40"
>
<xpath
expr="//t[@t-call='hr_timesheet.portal_timesheet_table']"
position="before"
>
<div class="row">
<div class="col-12 col-md-6 pb-2">
<span style="font-weight:bold;">Planned Hours: </span>
<span
t-field="task.allocated_hours"
t-options="{&quot;widget&quot;: &quot;timesheet_uom_no_toggle&quot;}"
/>
<t t-if="task.allow_subtasks and task.subtask_count > 0">
<div>
<strong>Subtask Planned Hours: </strong>
<span
t-field="task.subtask_allocated_hours"
t-options="{&quot;widget&quot;: &quot;timesheet_uom_no_toggle&quot;}"
/>
</div>
</t>
</div>
<t t-if="task.billable_progress > 0">
<div class="col-12 col-md-6 pb-2">
<strong>Progress: </strong>
<t t-set="progress" t-value="task.billable_progress" />
<div
class="oe-project_working_time_task_portal progressbar"
t-attf-style="width: #{progress}%;"
>
<t t-esc="progress" />%
</div>
</div>
</t>
</div>
</xpath>
</template>
<template
id="portal_my_task_remaining_hours"
name="My Task: remaining hours"
inherit_id="hr_timesheet.portal_timesheet_table"
priority="40"
>
<xpath expr="//tr[@t-foreach='timesheets']" position="attributes">
<attribute name="t-if">not timesheet.exclude_from_sale_order</attribute>
</xpath>
<xpath expr="//tfoot/tr/th[last()]" position="replace">
<th class="text-end">
<div
t-esc="round(sum(timesheets.filtered(lambda t: not t.exclude_from_sale_order).mapped('unit_amount')), 2)"
t-options="{&quot;widget&quot;: &quot;float_time&quot;}"
/>
<div t-if="task.allocated_hours > 0">Remaining Hours: <span
t-field="task.billable_remaining_hours"
t-options="{&quot;widget&quot;: &quot;float_time&quot;}"
/></div>
</th>
</xpath>
</template>
</odoo>

View File

@@ -0,0 +1,175 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="project_working_time_view_task_form" model="ir.ui.view">
<field name="name">project.working.time.view.task.form</field>
<field name="model">project.task</field>
<field name="inherit_id" ref="hr_timesheet.view_task_form2_inherited" />
<field name="priority" eval="99" />
<field name="arch" type="xml">
<xpath expr="//field[@name='effective_hours']" position="after">
<span>
<label
class="font-weight-bold"
for="billable_effective_hours"
string="Billable Effective Hours"
invisible="non_billable_effective_hours == 0.0 or encode_uom_in_days"
/>
<label
class="font-weight-bold"
for="billable_effective_hours"
string="Billable Effective Days"
invisible="non_billable_effective_hours == 0.0 or not encode_uom_in_days"
/>
</span>
<field
name="billable_effective_hours"
widget="timesheet_uom"
class="mt-2"
invisible="non_billable_effective_hours == 0.0"
nolabel="1"
/>
<span>
<label
class="font-weight-bold"
for="non_billable_effective_hours"
string="Non Billable Effective Hours"
invisible="non_billable_effective_hours == 0.0 or encode_uom_in_days"
/>
<label
class="font-weight-bold"
for="non_billable_effective_hours"
string="Non Billable Effective Days"
invisible="non_billable_effective_hours == 0.0 or not encode_uom_in_days"
/>
</span>
<field
name="non_billable_effective_hours"
widget="timesheet_uom"
class="mt-2"
invisible="non_billable_effective_hours == 0.0"
nolabel="1"
/>
</xpath>
<xpath expr="//field[@name='subtask_effective_hours']" position="after">
<span>
<label
class="font-weight-bold"
for="subtask_billable_effective_hours"
string="Subtask Billable Effective Hours"
invisible="subtask_effective_hours == 0.0 or encode_uom_in_days"
/>
<label
class="font-weight-bold"
for="subtask_billable_effective_hours"
string="Subtask Billable Effective Days"
invisible="subtask_effective_hours == 0.0 or not encode_uom_in_days"
/>
</span>
<field
name="subtask_billable_effective_hours"
widget="timesheet_uom"
class="mt-2"
invisible="subtask_effective_hours == 0.0"
nolabel="1"
/>
<span>
<label
class="font-weight-bold"
for="subtask_non_billable_effective_hours"
string="Subtask Non Billable Effective Hours"
invisible="subtask_effective_hours == 0.0 or encode_uom_in_days"
/>
<label
class="font-weight-bold"
for="subtask_non_billable_effective_hours"
string="Subtask Non Billable Effective Days"
invisible="subtask_effective_hours == 0.0 or not encode_uom_in_days"
/>
</span>
<field
name="subtask_non_billable_effective_hours"
widget="timesheet_uom"
class="mt-2"
invisible="subtask_effective_hours == 0.0"
nolabel="1"
/>
</xpath>
<xpath expr="//field[@name='total_hours_spent']" position="after">
<span invisible="subtask_effective_hours == 0.0">
<label
for="total_billable_hours_spent"
string="Total Billable Hours"
invisible="encode_uom_in_days"
/>
<label
for="total_billable_hours_spent"
string="Total Billable Days"
invisible="not encode_uom_in_days"
/>
</span>
<field
name="total_billable_hours_spent"
widget="timesheet_uom"
nolabel="1"
invisible="subtask_effective_hours == 0.0"
/>
<span invisible="subtask_effective_hours == 0.0">
<label
for="total_non_billable_hours_spent"
string="Total Non Billable Hours"
invisible="encode_uom_in_days"
/>
<label
for="total_non_billable_hours_spent"
string="Total Non Billable Days"
invisible="not encode_uom_in_days"
/>
</span>
<field
name="total_non_billable_hours_spent"
widget="timesheet_uom"
nolabel="1"
invisible="subtask_effective_hours == 0.0"
/>
</xpath>
<xpath expr="//field[@name='remaining_hours']" position="after">
<span>
<label
class="font-weight-bold text-danger"
for="billable_remaining_hours"
string="Billable Remaining Hours"
invisible="allocated_hours == 0.0 or encode_uom_in_days or billable_remaining_hours &gt;= 0"
/>
<label
class="font-weight-bold"
for="billable_remaining_hours"
string="Billable Remaining Hours"
invisible="allocated_hours == 0.0 or encode_uom_in_days or billable_remaining_hours &lt; 0"
/>
<label
class="font-weight-bold text-danger"
for="billable_remaining_hours"
string="Billable Remaining Days"
invisible="allocated_hours == 0.0 or not encode_uom_in_days or billable_remaining_hours &gt;= 0"
/>
<label
class="font-weight-bold"
for="billable_remaining_hours"
string="Billable Remaining Days"
invisible="allocated_hours == 0.0 or not encode_uom_in_days or billable_remaining_hours &lt; 0"
/>
</span>
<field
name="billable_remaining_hours"
widget="timesheet_uom"
class="oe_subtotal_footer_separator"
invisible="allocated_hours == 0.0"
decoration-danger="billable_remaining_hours &lt; 0"
nolabel="1"
/>
</xpath>
</field>
</record>
</odoo>

View File

@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template
id="portal_tasks_list_inherit"
inherit_id="hr_timesheet.portal_tasks_list_inherit"
>
<xpath
expr="//thead//t[@t-if='not project or project.allow_timesheets']/th[@class='text-end']"
position="replace"
>
<th class="text-end">Billable hours</th>
</xpath>
<xpath
expr="//tbody//td[@t-if='not project or project.allow_timesheets']"
position="replace"
>
<td t-if="not project or project.allow_timesheets" class="text-end">
<t t-if="task.allow_timesheets and not is_uom_day">
<span
t-field="task.billable_effective_hours"
t-options='{"widget": "float_time"}'
/>
<t t-if="task.allocated_hours > 0"> / <span
t-field="task.allocated_hours"
t-options='{"widget": "float_time"}'
/>
</t>
</t>
</td>
</xpath>
</template>
</odoo>