project_portal_templates.xml 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <odoo>
  3. <template id="portal_my_task" inherit_id="project.portal_my_task" name="Portal: My Task with Timesheets">
  4. <xpath expr="//li[@id='task-nav']" position="before">
  5. <li t-if="timesheets and allow_timesheets" class="list-group-item d-grid flex-grow-1" id='nav-report'>
  6. <div class="o_download_pdf d-flex gap-1">
  7. <a class="btn btn-secondary flex-fill o_download_btn" t-att-href="task.get_portal_url(report_type='pdf', download=True)" title="Download"><i class="fa fa-download"/> Download</a>
  8. <a class="btn btn-secondary flex-fill o_print_btn o_project_timesheet_print" t-att-href="task.get_portal_url(report_type='pdf')" href="#" title="Print" target="_blank"><i class="fa fa-print"/> Print</a>
  9. </div>
  10. </li>
  11. </xpath>
  12. <xpath expr="//li[@id='nav-header']" position="after">
  13. <li t-if="timesheets and allow_timesheets" class="nav-item">
  14. <a class="nav-link ps-3" href="#task_timesheets">
  15. Timesheets
  16. </a>
  17. </li>
  18. </xpath>
  19. <xpath expr="//div[@id='card_body']" position="inside">
  20. <div class="container" t-if="timesheets and allow_timesheets">
  21. <hr class="mt-4 mb-1"/>
  22. <h5 id="task_timesheets" class="mt-2 mb-2" data-anchor="true">Timesheets</h5>
  23. <t t-call="hr_timesheet.portal_timesheet_table"/>
  24. </div>
  25. </xpath>
  26. <xpath expr="//div[@name='portal_my_task_planned_hours']" position="after">
  27. <div t-if="task.planned_hours > 0"><strong>Progress:</strong> <span t-field="task.progress"/>%</div>
  28. </xpath>
  29. <xpath expr="//div[@name='portal_my_task_planned_hours']/t" position="replace">
  30. <t t-call="hr_timesheet.portal_my_task_planned_hours_template"></t>
  31. </xpath>
  32. </template>
  33. <template id="portal_my_task_planned_hours_template">
  34. <t t-if="is_uom_day and timesheets._convert_hours_to_days(task.planned_hours) > 0">
  35. <strong>Allocated Days:</strong> <span t-esc="timesheets._convert_hours_to_days(task.planned_hours)" t-options='{"widget": "timesheet_uom"}'/>
  36. </t>
  37. <t t-if="not is_uom_day and task.planned_hours > 0" t-call="project.portal_my_task_planned_hours_template"></t>
  38. </template>
  39. <template id="portal_tasks_list_inherit" inherit_id="project.portal_tasks_list" name="Portal: My Tasks with Timesheets">
  40. <xpath expr="//t[@t-foreach='tasks']/tr" position="before">
  41. <t t-set="timesheet_ids" t-value="task.sudo().timesheet_ids"/>
  42. <t t-set="is_uom_day" t-value="timesheet_ids._is_timesheet_encode_uom_day()"/>
  43. </xpath>
  44. <xpath expr="//thead/tr/t[@t-set='number_of_header']" position="attributes">
  45. <attribute name="t-value">9</attribute>
  46. </xpath>
  47. <xpath expr="//thead/tr/th[@name='project_portal_milestones']" position="after">
  48. <th t-if="is_uom_day" class="text-end">Days Spent</th>
  49. <th t-else="" class="text-end">Hours Spent</th>
  50. </xpath>
  51. <xpath expr="//tbody/t/tr/td[@name='project_portal_milestones']" position="after">
  52. <td class="text-end">
  53. <t t-if="is_uom_day">
  54. <t t-out="timesheet_ids._convert_hours_to_days(task.effective_hours)"/>
  55. <span t-if="task.planned_hours > 0"> / <t t-out="timesheet_ids._convert_hours_to_days(task.planned_hours)"/></span>
  56. </t>
  57. <t t-else="">
  58. <span t-field="task.effective_hours" t-options='{"widget": "float_time"}'/>
  59. <t t-if="task.planned_hours > 0">
  60. /
  61. <span t-field="task.planned_hours" t-options='{"widget": "float_time"}'/>
  62. </t>
  63. </t>
  64. </td>
  65. </xpath>
  66. </template>
  67. <template id="portal_timesheet_table" name="Portal Timesheet Table">
  68. <table class="table table-sm">
  69. <thead>
  70. <tr>
  71. <th>Date</th>
  72. <th>Employee</th>
  73. <th>Description</th>
  74. <th t-if="is_uom_day" class="text-end">Days Spent</th>
  75. <th t-else="" class="text-end">Hours Spent</th>
  76. </tr>
  77. </thead>
  78. <tr t-foreach="timesheets" t-as="timesheet">
  79. <td><t t-esc="timesheet.date" t-options='{"widget": "date"}'/></td>
  80. <td><t t-esc="timesheet.employee_id.name"/></td>
  81. <td><t t-esc="timesheet.name"/></td>
  82. <td class="text-end">
  83. <span t-if="is_uom_day" t-esc="timesheet._get_timesheet_time_day()" t-options='{"widget": "timesheet_uom"}'/>
  84. <span t-else="" t-field="timesheet.unit_amount" t-options='{"widget": "float_time"}'/>
  85. </td>
  86. </tr>
  87. <tfoot>
  88. <tr>
  89. <th colspan="3"></th>
  90. <th class="text-end">
  91. <t t-set="timesheets_amount" t-value="round(sum(timesheets.mapped('unit_amount')), 2) or 0.0"></t>
  92. <div t-if="is_uom_day"><strong>Days Spent:</strong> <span t-esc="timesheets._convert_hours_to_days(timesheets_amount)" t-options='{"widget": "timesheet_uom"}'/></div>
  93. <div t-else=""><strong>Hours Spent:</strong> <span t-esc="timesheets_amount" t-options='{"widget": "float_time"}'/></div>
  94. <t t-set="timesheets_by_subtask_amount" t-value="round(sum(sum(timesheet_by_subtask.mapped('unit_amount') or 0.0) for timesheet_by_subtask in timesheets_by_subtask.values()), 2) or 0.0"></t>
  95. <div t-if="timesheets_by_subtask">
  96. <div t-if="is_uom_day">Days recorded on sub-tasks: <span t-esc="timesheets._convert_hours_to_days(timesheets_by_subtask_amount)" t-options='{"widget": "timesheet_uom"}'/></div>
  97. <div t-else="">Hours recorded on sub-tasks: <span t-esc="timesheets_by_subtask_amount" t-options='{"widget": "float_time"}'/></div>
  98. </div>
  99. <t t-set="planned_time" t-value="task.planned_hours"></t>
  100. <div t-if="planned_time > 0" name="planned_time" t-attf-class="{{task.remaining_hours &lt; 0 and 'text-danger' or ''}}">
  101. <div t-if="is_uom_day">Remaining Days: <span t-esc="timesheets._convert_hours_to_days(planned_time - timesheets_amount - timesheets_by_subtask_amount)" t-options='{"widget": "timesheet_uom"}'/></div>
  102. <div t-else="">Remaining Hours: <span t-esc="planned_time - timesheets_amount - timesheets_by_subtask_amount" t-options='{"widget": "float_time"}'/></div>
  103. </div>
  104. </th>
  105. </tr>
  106. </tfoot>
  107. </table>
  108. </template>
  109. </odoo>