Skip to content

Commit c6b6411

Browse files
[ADD] document_page_project_task: add new module
1 parent 97e75cd commit c6b6411

19 files changed

Lines changed: 1437 additions & 0 deletions

File tree

Lines changed: 267 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,267 @@
1+
==========================
2+
Document Page Project Task
3+
==========================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:792f27beb9e30e02336420e9ffafb95a1a3027dc4b2ff368b4d350c683de3b01
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%2Fknowledge-lightgray.png?logo=github
20+
:target: https://github.com/OCA/knowledge/tree/16.0/document_page_project_task
21+
:alt: OCA/knowledge
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/knowledge-16-0/knowledge-16-0-document_page_project_task
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/knowledge&target_branch=16.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module extends the document page (wiki) functionality by allowing
32+
you to link them directly to project tasks.
33+
34+
Main Features
35+
-------------
36+
37+
- **Link Wiki Pages to Tasks**: Allows associating document pages to
38+
specific project tasks
39+
- **Automatic Project Filling**: When a task is selected, the related
40+
project is automatically filled
41+
- **Consistency Validation**: Ensures that the wiki page's project is
42+
always the same as the linked task's project
43+
- **Smart Filtering**: When a project is defined, only tasks from that
44+
project are displayed for selection
45+
- **Page Counter**: Displays the number of wiki pages linked to each
46+
task directly in the task view
47+
48+
Benefits
49+
--------
50+
51+
- Organize project documentation hierarchically (Project → Task → Wiki)
52+
- Keep documentation close to the work context (tasks)
53+
- Avoid inconsistencies between projects and tasks through automatic
54+
validations
55+
- Quickly access documentation related to a specific task
56+
57+
Dependencies
58+
------------
59+
60+
This module requires:
61+
62+
- ``document_page_project``: Module that links document pages to
63+
projects
64+
- ``project``: Odoo's project management module
65+
66+
**Table of contents**
67+
68+
.. contents::
69+
:local:
70+
71+
Configuration
72+
=============
73+
74+
This module does not require additional configuration after
75+
installation. It works automatically once installed.
76+
77+
Installation
78+
------------
79+
80+
1. Go to the **Apps** menu
81+
2. Remove the "Apps" filter if necessary
82+
3. Search for "Document Page Project Task"
83+
4. Click **Install**
84+
85+
Prerequisites
86+
-------------
87+
88+
Make sure the following modules are installed:
89+
90+
- **Project** (base project module)
91+
- **Document Page Project** (links wiki pages to projects)
92+
93+
The system will automatically install the necessary dependencies during
94+
installation.
95+
96+
Permissions
97+
-----------
98+
99+
The module uses the same access permissions as the base modules:
100+
101+
- Users with access to **Projects** can view and create wiki pages
102+
linked to tasks
103+
- Users with access to **Documents/Knowledge** can manage wiki page
104+
content
105+
106+
No additional permission configuration is required.
107+
108+
Usage
109+
=====
110+
111+
This guide explains how to use the Document Page Project Task module to
112+
link wiki pages to project tasks.
113+
114+
Create a Wiki Page from a Task
115+
------------------------------
116+
117+
**Method 1: From the Task**
118+
119+
1. Go to the **Projects** module
120+
2. Open the desired project
121+
3. Select a task
122+
4. In the task view, locate the **Wiki Pages** button (book icon)
123+
5. Click the button to see linked pages or create a new one
124+
6. Click **Create** to add a new wiki page
125+
7. The task and project will be automatically filled
126+
127+
**Method 2: From the Wiki Page**
128+
129+
1. Go to the **Knowledge** or **Documents** module
130+
2. Create a new wiki page or edit an existing one
131+
3. In the page form, you will see the fields:
132+
133+
- **Project**: Select the project
134+
- **Task**: Select the task (only tasks from the selected project
135+
will be displayed)
136+
137+
4. When you select a task, the project will be automatically filled
138+
5. Save the page
139+
140+
Automatic Behaviors
141+
-------------------
142+
143+
**Automatic Project Filling**
144+
145+
When you select a task:
146+
147+
- The **Project** field is automatically filled with the task's project
148+
- This ensures consistency between task and project
149+
150+
**Task Filtering**
151+
152+
When a project is selected:
153+
154+
- Only tasks from that project appear in the selection list
155+
- This prevents selecting tasks from different projects
156+
157+
**Consistency Validation**
158+
159+
The system automatically validates that:
160+
161+
- If a task is linked, the project must also be defined
162+
- The wiki page's project must be the same as the linked task's project
163+
- If you try to link a task to a different project, the system will
164+
prevent the operation
165+
166+
**Automatic Cleanup**
167+
168+
When you change the project:
169+
170+
- If the linked task does not belong to the new project, it is
171+
automatically removed
172+
- This maintains data consistency
173+
174+
View Wiki Pages of a Task
175+
-------------------------
176+
177+
1. Access a project task
178+
2. At the top of the form, you will see the **Wiki Pages** button with a
179+
counter
180+
3. The displayed number indicates how many wiki pages are linked to the
181+
task
182+
4. Click the button to see all linked pages
183+
184+
Usage Examples
185+
--------------
186+
187+
**Example 1: Requirements Documentation**
188+
189+
1. Create a task "Define System Requirements"
190+
2. From the task, create a wiki page "Functional Requirements"
191+
3. Document the requirements in the wiki page
192+
4. The page will be linked to the task and project
193+
194+
**Example 2: Meeting Notes**
195+
196+
1. Create a task "Planning Meeting"
197+
2. Create a wiki page "Meeting Minutes"
198+
3. Document the discussed points
199+
4. The documentation will be organized and easy to find
200+
201+
**Example 3: Technical Specifications**
202+
203+
1. Create a task "Develop Module X"
204+
2. Create a wiki page "Technical Specification"
205+
3. Document the architecture and technical decisions
206+
4. Keep the documentation close to the task work
207+
208+
Tips
209+
----
210+
211+
- Use wiki pages to maintain contextual documentation related to
212+
specific tasks
213+
- The page counter on the task helps quickly identify tasks with
214+
documentation
215+
- When creating a page from the task, fields are automatically filled,
216+
saving time
217+
- Organize project documentation hierarchically: Project → Task → Wiki
218+
219+
Bug Tracker
220+
===========
221+
222+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/knowledge/issues>`_.
223+
In case of trouble, please check there if your issue has already been reported.
224+
If you spotted it first, help us to smash it by providing a detailed and welcomed
225+
`feedback <https://github.com/OCA/knowledge/issues/new?body=module:%20document_page_project_task%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
226+
227+
Do not contact contributors directly about support or help with technical issues.
228+
229+
Credits
230+
=======
231+
232+
Authors
233+
-------
234+
235+
* Escodoo
236+
237+
Contributors
238+
------------
239+
240+
- `ESCODOO <https://escodoo.com.br>`__:
241+
242+
- Marcel Savegnago <marcel.savegnago@escodoo.com.br>
243+
244+
Maintainers
245+
-----------
246+
247+
This module is maintained by the OCA.
248+
249+
.. image:: https://odoo-community.org/logo.png
250+
:alt: Odoo Community Association
251+
:target: https://odoo-community.org
252+
253+
OCA, or the Odoo Community Association, is a nonprofit organization whose
254+
mission is to support the collaborative development of Odoo features and
255+
promote its widespread use.
256+
257+
.. |maintainer-marcelsavegnago| image:: https://github.com/marcelsavegnago.png?size=40px
258+
:target: https://github.com/marcelsavegnago
259+
:alt: marcelsavegnago
260+
261+
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
262+
263+
|maintainer-marcelsavegnago|
264+
265+
This module is part of the `OCA/knowledge <https://github.com/OCA/knowledge/tree/16.0/document_page_project_task>`_ project on GitHub.
266+
267+
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: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2025 Escodoo <https://escodoo.com.br>
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
3+
4+
{
5+
"name": "Document Page Project Task",
6+
"summary": "This module links document pages to project tasks",
7+
"version": "16.0.1.0.0",
8+
"category": "Project",
9+
"author": "Escodoo, Odoo Community Association (OCA)",
10+
"maintainers": ["marcelsavegnago"],
11+
"website": "https://github.com/OCA/knowledge",
12+
"license": "AGPL-3",
13+
"depends": ["document_page_project"],
14+
"data": ["views/document_page_views.xml", "views/project_task_views.xml"],
15+
"installable": True,
16+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import document_page
2+
from . import project_task
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Copyright 2025 Marcel Savegnago - Escodoo <https://escodoo.com.br>
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
3+
4+
from odoo import _, api, fields, models
5+
from odoo.exceptions import ValidationError
6+
7+
8+
class DocumentPage(models.Model):
9+
_inherit = "document.page"
10+
11+
task_id = fields.Many2one(string="Task", comodel_name="project.task")
12+
13+
@api.onchange("task_id")
14+
def _onchange_task_id(self):
15+
"""Fill the project_id field with the task's related project."""
16+
if self.task_id and self.task_id.project_id:
17+
self.project_id = self.task_id.project_id
18+
19+
@api.onchange("project_id")
20+
def _onchange_project_id(self):
21+
"""Clear the task if the project is removed or changed and does not
22+
match the task's project."""
23+
if self.task_id:
24+
if not self.project_id or self.task_id.project_id != self.project_id:
25+
self.task_id = False
26+
27+
@api.constrains("task_id", "project_id")
28+
def _check_task_project_consistency(self):
29+
"""Ensure that the project is the same as the task's project when a
30+
task is defined."""
31+
for record in self:
32+
# If there is a task, there must be a project
33+
if record.task_id and not record.project_id:
34+
raise ValidationError(
35+
_(
36+
"When a task is linked, the project must be defined. "
37+
"Task '%(task)s' requires that the project be defined.",
38+
task=record.task_id.name,
39+
)
40+
)
41+
# If there is a task and project, they must be from the same project
42+
if record.task_id and record.project_id:
43+
if record.task_id.project_id != record.project_id:
44+
raise ValidationError(
45+
_(
46+
"The wiki document's project must be the same as the "
47+
"task's project. Task '%(task)s' belongs to project "
48+
"'%(task_project)s', but the document is associated "
49+
"with project '%(doc_project)s'.",
50+
task=record.task_id.name,
51+
task_project=record.task_id.project_id.name,
52+
doc_project=record.project_id.name,
53+
)
54+
)
55+
56+
@api.model
57+
def default_get(self, fields_list):
58+
"""Fill the project_id when the wiki is created with default_task_id
59+
in the context."""
60+
res = super().default_get(fields_list)
61+
if "default_task_id" in self.env.context and "project_id" in fields_list:
62+
task = self.env["project.task"].browse(
63+
self.env.context.get("default_task_id")
64+
)
65+
if task.exists() and task.project_id:
66+
res["project_id"] = task.project_id.id
67+
return res
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright 2025 Marcel Savegnago - Escodoo <https://escodoo.com.br>
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
3+
4+
from odoo import api, fields, models
5+
6+
7+
class ProjectTask(models.Model):
8+
_inherit = "project.task"
9+
10+
document_page_ids = fields.One2many(
11+
string="Wiki Pages", comodel_name="document.page", inverse_name="task_id"
12+
)
13+
document_page_count = fields.Integer(compute="_compute_document_page_count")
14+
15+
@api.depends("document_page_ids")
16+
def _compute_document_page_count(self):
17+
for rec in self:
18+
rec.document_page_count = len(rec.document_page_ids)

0 commit comments

Comments
 (0)