Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 124 additions & 0 deletions project_task_create_portal/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
==================================
Project Portal Own Task Management
==================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:f6fee54148af1a81d39ccb70dc0f942f5a66150694fcebf82c733be3177601b0
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fproject-lightgray.png?logo=github
:target: https://github.com/OCA/project/tree/16.0/project_task_create_portal
:alt: OCA/project
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/project-16-0/project-16-0-project_task_create_portal
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/project&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module extends the Project application by enabling portal users to create new tasks and edit their own tasks directly from the Odoo portal.


## Features

- New field on project: **Portal Task Creation Stage**
- Portal users can create tasks in the pre-defined stages for allowed projects
- Extended portal UI:
- **“Create Task”** button visible for allowed project
- Simplified task creation form (Name, Description, Deadline)

**Table of contents**

.. contents::
:local:

Configuration
=============

## To configure the project for task creation from the portal

- Go to the Project App
- On a project kanban card, press the Settings button
- Go to the "Settings" tab

- Set the **Portal Task Creation Stage** to a stage (from the project’s stages) from which portal users will be allowed to add tasks.
- Set the **Hide assigned user** to hide the assigned user of the task on the portal.

Usage
=====

## To create a task from the portal


- Go to the portal, navigate to Projects
- Select an available project
- Press the “New Task” button
- In the form view, fill in:
- Name (required)
- Description (required)
- Deadline (optional)
- Press the Save button

## To edit a task from the portal

Note: the user can edit only their own tasks created

- Go to the portal, navigate to Projects
- Select an available project
- Select a task in the stage permitted for task creation and task editing

@gfcapalbo gfcapalbo Nov 14, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edit button not visible on task form. should be under

    task, history , does not show. (explanation of reason in other comments)

- Press the "Edit" button
- In the form view, edit the:
- Name
- Description
- Deadline
- Press the Save button


Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/project/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/project/issues/new?body=module:%20project_task_create_portal%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Contributors
~~~~~~~~~~~~

- [XXP](https://xxp-odoo.com):
- Maksim Shurupov
- Mike Lapin

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/project <https://github.com/OCA/project/tree/16.0/project_task_create_portal>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions project_task_create_portal/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import controllers
from . import models
33 changes: 33 additions & 0 deletions project_task_create_portal/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "Project Portal Own Task Management",
"version": "16.0.1.0.0",
"summary": "Allow portal users to create and edit their own tasks"
"from the portal only in a project's pre-configured task stage.",
"author": "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/project",
"license": "AGPL-3",
"category": "Project",
"depends": [
"web_editor",
"project",
"portal",
],
"data": [
"security/ir.model.access.csv",
"security/project_task_security.xml",
"views/portal_template.xml",
"views/project_project_views.xml",
],
"demo": [
"demo/project_task_create_portal_demo.xml",
],
"assets": {
"web.assets_frontend": [
"project_task_create_portal/static/src/js/portal.js",
],
"web_editor.assets_wysiwyg": {
"project_task_create_portal/static/src/xml/portal_wysiwyg.xml",
},
},
"installable": True,
}
1 change: 1 addition & 0 deletions project_task_create_portal/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import portal
199 changes: 199 additions & 0 deletions project_task_create_portal/controllers/portal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
from odoo import _, http
from odoo.exceptions import AccessError, MissingError
from odoo.fields import Date
from odoo.http import request

from odoo.addons.project.controllers.portal import ProjectCustomerPortal


class ProjectCustomerNewPortal(ProjectCustomerPortal):
@property
def mandatory_task_fields(self) -> list:
"""Mandatory task fields for portal user"""
return ["name", "description"]

@property
def optional_task_fields(self) -> list:
"""Optional task fields for portal user"""
return ["date_deadline"]

def _validate_task_fields(self, data, task_creation=False) -> tuple:
"""Validate task values submitted from the portal form."""
error, error_message = dict(), []

# Validation
for field_name in self.mandatory_task_fields:
if not data.get(field_name):
error[field_name] = "missing"

# Deadline validation
date_deadline = data.get("date_deadline")
if date_deadline:
date = Date.to_date(data.get("date_deadline"))
if date and date < Date.today():
error["date_deadline"] = "invalid"
error_message.append("Deadline is in the past")

return error, error_message

def _prepare_task_values(self, data) -> dict:
"""
Prepare task values
:param dict data: post values
:return: prepared task values
"""
values = {key: data[key] for key in self.mandatory_task_fields}
values.update(
{
key: data[key]
for key in self.optional_task_fields
if key in data and data.get(key)
}
)
return values

def _task_action_page_view_values(self, project) -> dict:
"""
Prepare values for task action page view
:param project: project.project
:return: dict
"""
values = self._prepare_portal_layout_values()
values.update(
{
"project": project,
"error": {},
"error_message": [],
}
)
return values

@http.route(
["/my/projects/<int:project_id>/task/new"],
type="http",
auth="user",
website=True,
)
def portal_project_create_task(self, project_id=None, **post) -> http.Response:
"""
Create a task in a project
:param int project_id: project
:param dict post: post values
"""
project = request.env["project.project"].sudo().browse(project_id).exists()
if not project:
raise MissingError(_("Project not found!"))
if not project.is_portal_task_creation_allowed():
raise AccessError(_("You are not allowed to create tasks in this project."))
values = self._task_action_page_view_values(project)
if post and request.httprequest.method == "POST":
error, error_message = self._validate_task_fields(post)
if not error:
values = self._prepare_task_values(post)
values["project_id"] = project.id
task = request.env["project.task"].create(values)
return request.redirect(f"/my/projects/{project_id}/task/{task.id}")
values.update({"error": error, "error_message": error_message, **post})
values.update({"page_name": "task_creation", "button": _("Create")})
return request.render(
"project_task_create_portal.portal_project_task_new", values
)

@http.route(
["/my/projects/<int:project_id>/task/<int:task_id>/edit"],
type="http",
auth="user",
website=True,
)
def portal_project_edit_task(self, project_id=None, task_id=None, **post):
"""
Edit a task in a project
:param int project_id: project.project record id
:param int task_id: project.task record id
:param dict post: post values
"""
task = request.env["project.task"].search(
[("id", "=", task_id), ("project_id", "=", project_id)]
)
if not task:
raise MissingError(_("Task not found!"))
if not task.check_portal_edit_access():
raise AccessError(_("You are not allowed to edit this task."))
values = self._task_action_page_view_values(task.project_id)
values.update(
{
"task": task,
"name": task.name,
"description": task.description,
"date_deadline": task.date_deadline,
"button": _("Save"),
}
)
if post and request.httprequest.method == "POST":
error, error_message = self._validate_task_fields(post)
if not error:
task.write(self._prepare_task_values(post))
return request.redirect(f"/my/projects/{project_id}/task/{task_id}")
values.update({"error": error, "error_message": error_message, **post})
values.update({"page_name": "task_edit"})
return request.render(
"project_task_create_portal.portal_project_task_new", values
)

def _project_get_page_view_values(
self,
project,
access_token,
page=1,
date_begin=None,
date_end=None,
sortby=None,
search=None,
search_in="content",
groupby=None,
**kwargs,
):
"""Add portal task creation availability to project page values."""
values = super()._project_get_page_view_values(
project,
access_token,
page,
date_begin,
date_end,
sortby,
search,
search_in,
groupby,
**kwargs,
)
# Access to visible create task button
values[
"searchbar_create_task"
] = project.sudo().is_portal_task_creation_allowed()
return values

def _task_get_searchbar_groupby(self, milestones_allowed):
"""Add task creator to the available portal grouping options."""
values = super()._task_get_searchbar_groupby(milestones_allowed)
values.update(
create_uid={"input": "create_uid", "label": _("Created by"), "order": 12}
)
return dict(sorted(values.items(), key=lambda item: item[1]["order"]))

def _task_get_searchbar_sortings(self, milestones_allowed):
"""Add task creator to the available portal sorting options."""
values = super()._task_get_searchbar_sortings(milestones_allowed)
values.update(
create_uid={
"label": _("Created by"),
"order": "create_uid desc",
"sequence": 12,
}
)
return values

def _task_get_groupby_mapping(self):
"""Map the portal creator grouping option to ``create_uid``."""
result = super()._task_get_groupby_mapping()
result.update(create_uid="create_uid")
return result
Loading
Loading