Skip to content
Merged
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ addon | version | maintainers | summary
[project_task_code](project_task_code/) | 18.0.1.0.1 | | Sequential Code for Tasks
[project_task_code_portal](project_task_code_portal/) | 18.0.1.1.1 | | Use custom task code in customer portal
[project_task_default_stage](project_task_default_stage/) | 18.0.1.0.1 | | Recovery default task stages for projects from v8
[project_task_default_user](project_task_default_user/) | 18.0.1.0.0 | <a href='https://github.com/NICO-SOLUTIONS'><img src='https://github.com/NICO-SOLUTIONS.png' width='32' height='32' style='border-radius:50%;' alt='NICO-SOLUTIONS'/></a> | Auto assign default users to tasks or when changing task stages
[project_task_description_portal](project_task_description_portal/) | 18.0.1.0.0 | | Dedicated task description for portal users
[project_task_description_template](project_task_description_template/) | 18.0.1.0.0 | | Add a description template to project tasks
[project_task_material](project_task_material/) | 18.0.1.0.0 | | Record products spent in a Task
Expand Down
120 changes: 120 additions & 0 deletions project_task_default_user/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

=========================
Project Task Default User
=========================

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

.. |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/license-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/18.0/project_task_default_user
:alt: OCA/project
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/project-18-0/project-18-0-project_task_default_user
: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=18.0
:alt: Try me on Runboat

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

This module automatically assigns default users to tasks.

- Stage-based assignment (priority rule): When creating a task or
changing its stage to one with default users, those users are
automatically assigned according to the stage’s assignment mode
(replace or merge). Stage-based defaults always take priority over
project defaults.
- Project-based fallback: If the stage does not define any default
users, project default users are applied using the same assignment
mode logic (replace or merge).
- Assignment behavior: The assignment mode controls how users are
applied:

- replace: replaces existing task users with default users
- merge: adds default users to the existing task users without
removing them

- Multiple default users supported: Both project and stage can define
multiple default users.

**Table of contents**

.. contents::
:local:

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

To use this module, you need to:

1. Open Project settings and set default users in the "Default Users"
tab and configure the assignment mode.
2. Activate developer mode.
3. Go to Project → Configuration → Task Stages, set default users in the
"Default Users for this Stage" field and configure the assignment
mode.

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_default_user%0Aversion:%2018.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
=======

Authors
-------

* NICO SOLUTIONS - ENGINEERING & IT

Contributors
------------

- `NICO SOLUTIONS - ENGINEERING & IT <https://www.nico-solutions.de>`__:

- Nils Coenen <nils.coenen@nico-solutions.de>

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.

.. |maintainer-NICO-SOLUTIONS| image:: https://github.com/NICO-SOLUTIONS.png?size=40px
:target: https://github.com/NICO-SOLUTIONS
:alt: NICO-SOLUTIONS

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-NICO-SOLUTIONS|

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

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions project_task_default_user/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
21 changes: 21 additions & 0 deletions project_task_default_user/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2025 NICO SOLUTIONS - ENGINEERING & IT
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

{
"name": "Project Task Default User",
"summary": "Auto assign default users to tasks or when changing task stages",
"version": "18.0.1.0.0",
"category": "Project",
"author": "NICO SOLUTIONS - ENGINEERING & IT, Odoo Community Association (OCA)",
"maintainers": ["NICO-SOLUTIONS"],
"website": "https://github.com/OCA/project",
"depends": ["project"],
"data": [
"views/project_project_views.xml",
"views/project_task_type_views.xml",
],
"license": "AGPL-3",
"installable": True,
"application": False,
"auto_install": False,
}
86 changes: 86 additions & 0 deletions project_task_default_user/i18n/project_task_default_user.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * project_task_default_user
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 18.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: project_task_default_user
#: model:ir.model.fields,field_description:project_task_default_user.field_project_project__default_user_ids
msgid "Default Users for Tasks"
msgstr ""

#. module: project_task_default_user
#: model:ir.model.fields,field_description:project_task_default_user.field_project_task_type__default_user_ids
msgid "Default Users for this Stage"
msgstr ""

#. module: project_task_default_user
#: model_terms:ir.ui.view,arch_db:project_task_default_user.project_edit_project_inherit_default_user
msgid "Default users"
msgstr ""

#. module: project_task_default_user
#: model:ir.model.fields,help:project_task_default_user.field_project_project__project_task_assignment_mode
#: model:ir.model.fields,help:project_task_default_user.field_project_task_type__stage_task_assignment_mode
msgid ""
"Defines how default users are applied:\n"
"- Replace: overwrite existing users\n"
"- Merge: add default users to existing ones\n"
"\n"
"Applied on task creation and stage changes."
msgstr ""

#. module: project_task_default_user
#: model:ir.model.fields,help:project_task_default_user.field_project_project__default_user_ids
#: model:ir.model.fields,help:project_task_default_user.field_project_task_type__default_user_ids
msgid ""
"If set, tasks will automatically be assigned to these users. On new tasks, "
"this applies if no users are set. On stage change, the users are replaced "
"only if the new stage has default users."
msgstr ""

#. module: project_task_default_user
#: model:ir.model.fields.selection,name:project_task_default_user.selection__project_project__project_task_assignment_mode__merge
#: model:ir.model.fields.selection,name:project_task_default_user.selection__project_task_type__stage_task_assignment_mode__merge
msgid "Merge"
msgstr ""

#. module: project_task_default_user
#: model:ir.model,name:project_task_default_user.model_project_project
msgid "Project"
msgstr ""

#. module: project_task_default_user
#: model:ir.model.fields,field_description:project_task_default_user.field_project_project__project_task_assignment_mode
msgid "Project Task Assignment Mode"
msgstr ""

#. module: project_task_default_user
#: model:ir.model.fields.selection,name:project_task_default_user.selection__project_project__project_task_assignment_mode__replace
#: model:ir.model.fields.selection,name:project_task_default_user.selection__project_task_type__stage_task_assignment_mode__replace
msgid "Replace"
msgstr ""

#. module: project_task_default_user
#: model:ir.model.fields,field_description:project_task_default_user.field_project_task_type__stage_task_assignment_mode
msgid "Stage Task Assignment Mode"
msgstr ""

#. module: project_task_default_user
#: model:ir.model,name:project_task_default_user.model_project_task
msgid "Task"
msgstr ""

#. module: project_task_default_user
#: model:ir.model,name:project_task_default_user.model_project_task_type
msgid "Task Stage"
msgstr ""
5 changes: 5 additions & 0 deletions project_task_default_user/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from . import project_project
from . import project_task_type
from . import project_task
33 changes: 33 additions & 0 deletions project_task_default_user/models/project_project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2025 NICO SOLUTIONS - ENGINEERING & IT
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from odoo import fields, models


class ProjectProject(models.Model):
_inherit = "project.project"

default_user_ids = fields.Many2many(
"res.users",
string="Default Users for Tasks",
domain=lambda self: [
("groups_id", "in", [self.env.ref("project.group_project_user").id])
],
help="If set, tasks will automatically be assigned to these users. "
"On new tasks, this applies if no users are set. On stage change, "
"the users are replaced only if the new stage has default users.",
)
project_task_assignment_mode = fields.Selection(
[
("replace", "Replace"),
("merge", "Merge"),
],
default="replace",
help=(
"Defines how default users are applied:\n"
"- Replace: overwrite existing users\n"
"- Merge: add default users to existing ones\n"
"\n"
"Applied on task creation and stage changes."
),
)
53 changes: 53 additions & 0 deletions project_task_default_user/models/project_task.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Copyright 2025 NICO SOLUTIONS - ENGINEERING & IT
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from odoo import Command, api, models


class ProjectTask(models.Model):
_inherit = "project.task"

@api.model_create_multi
def create(self, vals_list):
tasks = super().create(vals_list)
for task in tasks:
default_users, mode = task._get_default_users_and_mode()
if default_users:
task._apply_default_users(default_users, mode)

return tasks

def write(self, vals):
res = super().write(vals)
if "stage_id" in vals:
for task in self:
default_users, mode = task._get_default_users_and_mode()
if default_users:
task._apply_default_users(default_users, mode)

return res

def _get_default_users_and_mode(self):
self.ensure_one()
if self.stage_id and self.stage_id.default_user_ids:
return (
self.stage_id.default_user_ids.ids,
self.stage_id.stage_task_assignment_mode or "replace",
)

if self.project_id and self.project_id.default_user_ids:
return (
self.project_id.default_user_ids.ids,
self.project_id.project_task_assignment_mode or "replace",
)

return None, "replace"

def _apply_default_users(self, default_users, mode):
self.ensure_one()
if mode == "merge":
existing = self.user_ids.ids or []
merged = list(dict.fromkeys(existing + default_users))
self.user_ids = [Command.set(merged)]
else:
self.user_ids = [Command.set(default_users)]
33 changes: 33 additions & 0 deletions project_task_default_user/models/project_task_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2025 NICO SOLUTIONS - ENGINEERING & IT
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from odoo import fields, models


class ProjectTaskType(models.Model):
_inherit = "project.task.type"

default_user_ids = fields.Many2many(
"res.users",
string="Default Users for this Stage",
domain=lambda self: [
("groups_id", "in", [self.env.ref("project.group_project_user").id])
],
help="If set, tasks will automatically be assigned to these users. "
"On new tasks, this applies if no users are set. On stage change, "
"the users are replaced only if the new stage has default users.",
)
stage_task_assignment_mode = fields.Selection(
[
("replace", "Replace"),
("merge", "Merge"),
],
default="replace",
help=(
"Defines how default users are applied:\n"
"- Replace: overwrite existing users\n"
"- Merge: add default users to existing ones\n"
"\n"
"Applied on task creation and stage changes."
),
)
3 changes: 3 additions & 0 deletions project_task_default_user/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
5 changes: 5 additions & 0 deletions project_task_default_user/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
To use this module, you need to:

1. Open Project settings and set default users in the "Default Users" tab and configure the assignment mode.
2. Activate developer mode.
3. Go to Project → Configuration → Task Stages, set default users in the "Default Users for this Stage" field and configure the assignment mode.
2 changes: 2 additions & 0 deletions project_task_default_user/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- [NICO SOLUTIONS - ENGINEERING & IT](https://www.nico-solutions.de):
- Nils Coenen \<<nils.coenen@nico-solutions.de>\>
7 changes: 7 additions & 0 deletions project_task_default_user/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
This module automatically assigns default users to tasks.
- Stage-based assignment (priority rule): When creating a task or changing its stage to one with default users, those users are automatically assigned according to the stage’s assignment mode (replace or merge). Stage-based defaults always take priority over project defaults.
- Project-based fallback: If the stage does not define any default users, project default users are applied using the same assignment mode logic (replace or merge).
- Assignment behavior: The assignment mode controls how users are applied:
- replace: replaces existing task users with default users
- merge: adds default users to the existing task users without removing them
- Multiple default users supported: Both project and stage can define multiple default users.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading