Skip to content

Commit 722aff7

Browse files
[ADD] project_task_default_user
This module automatically assigns default users to tasks: - Project-based: New tasks inherit the project's default users if the stage has no defaults. - Stage-based: When creating or moving a task to a stage with default users, these users are automatically assigned, replacing any existing users. - Multiple default users can be set
1 parent a06cdf5 commit 722aff7

17 files changed

+824
-0
lines changed
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
=========================
2+
Project Task Default User
3+
=========================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:ad4071f80cb9b713b83ef081af888e37e8b3a19dd0cde6415eecb13714542822
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fproject-lightgray.png?logo=github
20+
:target: https://github.com/OCA/project/tree/18.0/project_task_default_user
21+
:alt: OCA/project
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/project-18-0/project-18-0-project_task_default_user
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/project&target_branch=18.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module automatically assigns default users to tasks
32+
33+
- Project-based: When creating a new task in a stage without default
34+
users, it inherits the default users set on the project, if any.
35+
Otherwise, no user is assigned automatically.
36+
- Stage-based: When creating or moving a task to a stage with default
37+
users, these users are automatically assigned, replacing any existing
38+
users.
39+
- Multiple default users can be set
40+
41+
**Table of contents**
42+
43+
.. contents::
44+
:local:
45+
46+
Configuration
47+
=============
48+
49+
To use this module, you need to:
50+
51+
1. Open the Project-settings > Set default users in "Default Users" page
52+
tab
53+
2. Activate the developer mode.
54+
3. Open Project > Configuration > Task Stages. Set default users in
55+
field "Default Users for this Stage"
56+
57+
Bug Tracker
58+
===========
59+
60+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/project/issues>`_.
61+
In case of trouble, please check there if your issue has already been reported.
62+
If you spotted it first, help us to smash it by providing a detailed and welcomed
63+
`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**>`_.
64+
65+
Do not contact contributors directly about support or help with technical issues.
66+
67+
Credits
68+
=======
69+
70+
Authors
71+
-------
72+
73+
* NICO SOLUTIONS - ENGINEERING & IT
74+
75+
Contributors
76+
------------
77+
78+
- `NICO SOLUTIONS - ENGINEERING &
79+
IT <https://www.nico-solutions.de>`__:
80+
81+
- Nils Coenen <[email protected]>
82+
83+
Maintainers
84+
-----------
85+
86+
This module is maintained by the OCA.
87+
88+
.. image:: https://odoo-community.org/logo.png
89+
:alt: Odoo Community Association
90+
:target: https://odoo-community.org
91+
92+
OCA, or the Odoo Community Association, is a nonprofit organization whose
93+
mission is to support the collaborative development of Odoo features and
94+
promote its widespread use.
95+
96+
.. |maintainer-NICO-SOLUTIONS| image:: https://github.com/NICO-SOLUTIONS.png?size=40px
97+
:target: https://github.com/NICO-SOLUTIONS
98+
:alt: NICO-SOLUTIONS
99+
100+
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
101+
102+
|maintainer-NICO-SOLUTIONS|
103+
104+
This module is part of the `OCA/project <https://github.com/OCA/project/tree/18.0/project_task_default_user>`_ project on GitHub.
105+
106+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright 2025 NICO SOLUTIONS - ENGINEERING & IT
2+
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
3+
4+
{
5+
"name": "Project Task Default User",
6+
"summary": "Auto assign default users to tasks or when changing task stages",
7+
"version": "18.0.1.0.0",
8+
"category": "project",
9+
"author": "NICO SOLUTIONS - ENGINEERING & IT, Odoo Community Association (OCA)",
10+
"maintainers": ["NICO-SOLUTIONS"],
11+
"website": "https://github.com/OCA/project",
12+
"depends": ["project"],
13+
"data": [
14+
"views/project_project_views.xml",
15+
"views/project_task_type_views.xml",
16+
],
17+
"license": "AGPL-3",
18+
"installable": True,
19+
"application": False,
20+
"auto_install": False,
21+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
2+
3+
from . import project_project
4+
from . import project_task_type
5+
from . import project_task
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2025 NICO SOLUTIONS - ENGINEERING & IT
2+
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
3+
4+
from odoo import fields, models
5+
6+
7+
class ProjectProject(models.Model):
8+
_inherit = "project.project"
9+
10+
default_user_ids = fields.Many2many(
11+
"res.users",
12+
string="Default Users for Tasks",
13+
help="If set, tasks will automatically be assigned to these users. "
14+
"On new tasks, this applies if no users are set. On stage change, "
15+
"the users are replaced only if the new stage has default users.",
16+
)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Copyright 2025 NICO SOLUTIONS - ENGINEERING & IT
2+
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
3+
4+
from odoo import models
5+
6+
7+
class ProjectTask(models.Model):
8+
_inherit = "project.task"
9+
10+
def create(self, vals_list):
11+
tasks = super().create(vals_list)
12+
13+
for task in tasks:
14+
if not task.user_ids:
15+
default_users = []
16+
17+
stage = task.stage_id
18+
if stage and stage.default_user_ids:
19+
default_users = stage.default_user_ids.ids
20+
21+
if (
22+
not default_users
23+
and task.project_id
24+
and task.project_id.default_user_ids
25+
):
26+
default_users = task.project_id.default_user_ids.ids
27+
28+
if default_users:
29+
task.user_ids = [(6, 0, default_users)]
30+
31+
return tasks
32+
33+
def write(self, vals):
34+
res = super().write(vals)
35+
36+
if "stage_id" in vals:
37+
for task in self:
38+
stage = task.stage_id
39+
if stage and stage.default_user_ids:
40+
task.user_ids = [(6, 0, stage.default_user_ids.ids)]
41+
42+
return res
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2025 NICO SOLUTIONS - ENGINEERING & IT
2+
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
3+
4+
from odoo import fields, models
5+
6+
7+
class ProjectTaskType(models.Model):
8+
_inherit = "project.task.type"
9+
10+
default_user_ids = fields.Many2many(
11+
"res.users",
12+
string="Default Users for this Stage",
13+
help="If set, tasks will automatically be assigned to these users. "
14+
"On new tasks, this applies if no users are set. On stage change, "
15+
"the users are replaced only if the new stage has default users.",
16+
)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["whool"]
3+
build-backend = "whool.buildapi"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
To use this module, you need to:
2+
3+
1. Open the Project-settings > Set default users in "Default Users" page tab
4+
2. Activate the developer mode.
5+
3. Open Project > Configuration > Task Stages. Set default users in field "Default Users for this Stage"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- [NICO SOLUTIONS - ENGINEERING & IT](https://www.nico-solutions.de):
2+
- Nils Coenen \<<[email protected]>\>

0 commit comments

Comments
 (0)