[IMP] project: rename the portal form view route of project and task
Before this commit, when the current user is in the '/my/projects' route and selects a project the route becomes '/my/project/<id of project>'. There is no reason to change the route and then adding the id of the project. In sales order route, we keep the route and we add the id of the SO to see the portal form view of the SO selected. This commit renames the route of project and task form view to keep the same route and the same logic of SO and quotations routes for instance. task-2648955 Closes #82379
This commit is contained in:
@@ -63,7 +63,7 @@ class ProjectCustomerPortal(CustomerPortal):
|
||||
# task count
|
||||
task_count = Task.search_count(domain)
|
||||
# pager
|
||||
url = "/my/project/%s" % project.id
|
||||
url = "/my/projects/%s" % project.id
|
||||
pager = portal_pager(
|
||||
url=url,
|
||||
url_args={'date_begin': date_begin, 'date_end': date_end, 'sortby': sortby, 'groupby': groupby, 'search_in': search_in, 'search': search},
|
||||
@@ -146,7 +146,20 @@ class ProjectCustomerPortal(CustomerPortal):
|
||||
})
|
||||
return request.render("project.portal_my_projects", values)
|
||||
|
||||
@http.route(['/my/project/<int:project_id>'], type='http', auth="public", website=True)
|
||||
@http.route(['/my/project/<int:project_id>',
|
||||
'/my/project/<int:project_id>/page/<int:page>',
|
||||
'/my/project/<int:project_id>/task/<int:task_id>',
|
||||
'/my/project/<int:project_id>/project_sharing'], type='http', auth="public")
|
||||
def portal_project_routes_outdated(self, **kwargs):
|
||||
""" Redirect the outdated routes to the new routes. """
|
||||
return request.redirect(request.httprequest.path.replace('/my/project/', '/my/projects/'))
|
||||
|
||||
@http.route(['/my/task', '/my/task/page/<int:page>'], type='http', auth='public')
|
||||
def portal_my_task_routes_outdated(self, **kwargs):
|
||||
""" Redirect the outdated routes to the new routes. """
|
||||
return request.redirect(request.httprequest.path.replace('/my/task', '/my/tasks'))
|
||||
|
||||
@http.route(['/my/projects/<int:project_id>'], type='http', auth="public", website=True)
|
||||
def portal_my_project(self, project_id=None, access_token=None, page=1, date_begin=None, date_end=None, sortby=None, search=None, search_in='content', groupby=None, task_id=None, **kw):
|
||||
try:
|
||||
project_sudo = self._document_check_access('project.project', project_id, access_token)
|
||||
@@ -195,7 +208,7 @@ class ProjectCustomerPortal(CustomerPortal):
|
||||
session_info['open_task_action'] = task.action_project_sharing_open_task()
|
||||
return session_info
|
||||
|
||||
@http.route("/my/project/<int:project_id>/project_sharing", type="http", auth="user", methods=['GET'])
|
||||
@http.route("/my/projects/<int:project_id>/project_sharing", type="http", auth="user", methods=['GET'])
|
||||
def render_project_backend_view(self, project_id, task_id=None):
|
||||
project = request.env['project.project'].sudo().browse(project_id)
|
||||
if not project.exists() or not project.with_user(request.env.user)._check_project_sharing_access():
|
||||
@@ -206,7 +219,7 @@ class ProjectCustomerPortal(CustomerPortal):
|
||||
{'session_info': self._prepare_project_sharing_session_info(project, task)},
|
||||
)
|
||||
|
||||
@http.route('/my/project/<int:project_id>/task/<int:task_id>', type='http', auth='public', website=True)
|
||||
@http.route('/my/projects/<int:project_id>/task/<int:task_id>', type='http', auth='public', website=True)
|
||||
def portal_my_project_task(self, project_id=None, task_id=None, access_token=None, **kw):
|
||||
try:
|
||||
project_sudo = self._document_check_access('project.project', project_id, access_token)
|
||||
@@ -414,7 +427,7 @@ class ProjectCustomerPortal(CustomerPortal):
|
||||
'grouped_tasks': grouped_tasks,
|
||||
'page_name': 'task',
|
||||
'default_url': '/my/tasks',
|
||||
'task_url': 'task',
|
||||
'task_url': 'tasks',
|
||||
'pager': pager,
|
||||
'searchbar_sortings': searchbar_sortings,
|
||||
'searchbar_groupby': searchbar_groupby,
|
||||
@@ -433,7 +446,7 @@ class ProjectCustomerPortal(CustomerPortal):
|
||||
# The route should not be called if at least hr_timesheet is not installed
|
||||
raise MissingError(_('There is nothing to report.'))
|
||||
|
||||
@http.route(['/my/task/<int:task_id>'], type='http', auth="public", website=True)
|
||||
@http.route(['/my/tasks/<int:task_id>'], type='http', auth="public", website=True)
|
||||
def portal_my_task(self, task_id, report_type=None, access_token=None, **kw):
|
||||
try:
|
||||
task_sudo = self._document_check_access('project.task', task_id, access_token)
|
||||
|
||||
@@ -364,7 +364,7 @@ class Project(models.Model):
|
||||
def _compute_access_url(self):
|
||||
super(Project, self)._compute_access_url()
|
||||
for project in self:
|
||||
project.access_url = '/my/project/%s' % project.id
|
||||
project.access_url = f'/my/projects/{project.id}'
|
||||
|
||||
def _compute_access_warning(self):
|
||||
super(Project, self)._compute_access_warning()
|
||||
@@ -1397,7 +1397,7 @@ class Task(models.Model):
|
||||
def _compute_access_url(self):
|
||||
super(Task, self)._compute_access_url()
|
||||
for task in self:
|
||||
task.access_url = '/my/task/%s' % task.id
|
||||
task.access_url = f'/my/tasks/{task.id}'
|
||||
|
||||
def _compute_access_warning(self):
|
||||
super(Task, self)._compute_access_warning()
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<t t-else="">Projects</t>
|
||||
</li>
|
||||
<li t-if="page_name == 'project_task' and project" class="breadcrumb-item active">
|
||||
<a t-if="project" t-attf-href="/my/project/{{ project.id }}?{{ keep_query() }}"><t t-esc="project.name"/></a>
|
||||
<a t-if="project" t-attf-href="/my/projects/{{ project.id }}?{{ keep_query() }}"><t t-esc="project.name"/></a>
|
||||
</li>
|
||||
<li t-elif="project" t-attf-class="breadcrumb-item #{'active ' if not project else ''} text-truncate col-8 col-lg-10">
|
||||
<t t-esc="project.name"/>
|
||||
@@ -61,7 +61,7 @@
|
||||
<tbody>
|
||||
<tr t-foreach="projects" t-as="project">
|
||||
<td>
|
||||
<a t-attf-href="/my/project/#{project.id}?{{ keep_query() }}"><span t-field="project.name"/></a>
|
||||
<a t-attf-href="/my/projects/#{project.id}?{{ keep_query() }}"><span t-field="project.name"/></a>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<t t-out="project.task_count_with_subtasks" />
|
||||
@@ -262,7 +262,7 @@
|
||||
</div>
|
||||
<div class="row mb-4">
|
||||
<div class="col-12 col-md-6">
|
||||
<div t-if="project_accessible"><strong>Project:</strong> <a t-attf-href="/my/project/#{task.project_id.id}" t-field="task.project_id"/></div>
|
||||
<div t-if="project_accessible"><strong>Project:</strong> <a t-attf-href="/my/projects/#{task.project_id.id}" t-field="task.project_id"/></div>
|
||||
<div t-else=""><strong>Project:</strong> <a t-field="task.project_id"/></div>
|
||||
<div t-if="task.date_deadline"><strong>Deadline:</strong> <span t-field="task.date_deadline" t-options='{"widget": "date"}'/></div>
|
||||
<div name="portal_my_task_planned_hours">
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
</template>
|
||||
|
||||
<template id="project_sharing" name="Project Sharing View">
|
||||
<iframe width="100%" height="100%" frameborder="0" t-attf-src="/my/project/{{ project_id }}{{ '/' + task_id if task_id else '' }}/project_sharing"/>
|
||||
<iframe width="100%" height="100%" frameborder="0" t-attf-src="/my/projects/{{ project_id }}/project_sharing{{ '?task_id=' + task_id if task_id else '' }}"/>
|
||||
</template>
|
||||
|
||||
<template id="project_sharing_embed" name="Project Sharing View Embed">
|
||||
|
||||
@@ -322,7 +322,7 @@ class IrHttp(models.AbstractModel):
|
||||
record = record_sudo
|
||||
elif self.env.user.has_group('base.group_portal'):
|
||||
# Check the read access on the record linked to the attachment
|
||||
# eg: Allow to download an attachment on a task from /my/task/task_id
|
||||
# eg: Allow to download an attachment on a task from /my/tasks/task_id
|
||||
record.check('read')
|
||||
record = record_sudo
|
||||
|
||||
|
||||
Reference in New Issue
Block a user