1 Commits

5 changed files with 20 additions and 58 deletions

View File

@@ -3,7 +3,7 @@
{
"name": "project_average_acceptable_time",
"version": "18.0.1.0.0",
"version": "18.0.1.1.0",
"author": "Elabore",
"website": "https://git.elabore.coop/elabore/project-tools",
"maintainer": "Clément Thomas",

View File

@@ -17,9 +17,12 @@ class CustomCustomerPortal(CustomerPortal):
if post and request.httprequest.method == "POST":
error, error_message = self.details_form_validate(post)
if not error:
user = request.env.user
if user.default_project_id and post["average_acceptable_time"]:
user.default_project_id.average_acceptable_time = post[
# sudo: a portal user has no write access at all on
# project.project, and no read access on its default project
# unless it follows it
project_sudo = request.env.user.sudo().default_project_id
if project_sudo and post.get("average_acceptable_time"):
project_sudo.average_acceptable_time = post[
"average_acceptable_time"
]

View File

@@ -8,11 +8,19 @@
priority="40"
>
<xpath expr="//div[@class='o_portal_my_details']" position="inside">
<hr class="mt-1 mb-0" />
<b>Average acceptable time</b>: <t
t-esc="user_id.default_project_id.average_acceptable_time"
t-options="{'widget': 'float_time'}"
<!-- sudo: a portal user cannot read its own default project
unless it follows it (project.project_project_rule_portal) -->
<t
t-set="default_project_sudo"
t-value="user_id.sudo().default_project_id"
/>
<t t-if="default_project_sudo">
<hr class="mt-1 mb-0" />
<b>Average acceptable time</b>: <t
t-esc="default_project_sudo.average_acceptable_time"
t-options="{'widget': 'float_time'}"
/>
</t>
</xpath>
</template>
@@ -34,7 +42,7 @@
type="text"
name="average_acceptable_time"
t-attf-class="form-control #{error.get('average_acceptable_time') and 'is-invalid' or ''}"
t-att-value="average_acceptable_time or user_id.default_project_id.average_acceptable_time"
t-att-value="average_acceptable_time or user_id.sudo().default_project_id.average_acceptable_time"
t-options="{'widget': 'float_time'}"
/>
</div>

View File

@@ -26,7 +26,6 @@
# views/hr_timesheet_portal.xml",
"views/hr_timesheet_view_task_form2.xml",
"views/portal_tasks_list.xml",
"views/portal_my_task_with_subtasks.xml"
],
"assets": {
"web.assets_frontend": [

View File

@@ -1,48 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="hr_timesheet_portal_timesheet_table_inherit"
inherit_id="hr_timesheet.portal_timesheet_table">
<xpath expr="//table[hasclass('o_portal_my_doc_table')]" position="after">
<t t-foreach="task.child_ids" t-as="subtask">
<t t-if="subtask.billable_effective_hours > 0">
<a t-attf-href="/my/tasks/#{subtask.id}">
<span t-att-title="subtask.name" t-field="subtask.name" />
</a>
<t t-set="timesheets" t-value="subtask.timesheet_ids" />
<table class="o_portal_my_doc_table table table-sm table-striped">
<thead>
<tr>
<th>Date</th>
<th>Employee</th>
<th>Description</th>
<th class="text-end" name="t_label">Time Spent</th>
</tr>
</thead>
<tr t-foreach="timesheets" t-as="timesheet" valign="middle">
<td>
<t t-esc="timesheet.date" t-options='{"widget": "date"}' />
</td>
<td t-attf-title="#{timesheet.employee_id.name}">
<t t-esc="timesheet.employee_id.name" />
</td>
<td>
<t t-esc="timesheet.name" />
</td>
<td class="text-end">
<span t-if="is_uom_day" t-esc="timesheet._get_timesheet_time_day()"
t-options='{"widget": "timesheet_uom"}' />
<span t-else="" t-field="timesheet.unit_amount"
t-options='{"widget": "float_time"}' />
</td>
</tr>
</table>
</t>
</t>
</xpath>
</template>
</odoo>