Skip to content

Commit eb1b1d8

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

File tree

19 files changed

+1482
-0
lines changed

19 files changed

+1482
-0
lines changed
Lines changed: 285 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,285 @@
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+
Document Page Project Task
32+
==========================
33+
34+
This module extends the document page (wiki) functionality by allowing
35+
you to link them directly to project tasks.
36+
37+
Main Features
38+
-------------
39+
40+
- **Link Wiki Pages to Tasks**: Allows associating document pages to
41+
specific project tasks
42+
- **Automatic Project Filling**: When a task is selected, the related
43+
project is automatically filled
44+
- **Consistency Validation**: Ensures that the wiki page's project is
45+
always the same as the linked task's project
46+
- **Smart Filtering**: When a project is defined, only tasks from that
47+
project are displayed for selection
48+
- **Page Counter**: Displays the number of wiki pages linked to each
49+
task directly in the task view
50+
51+
Benefits
52+
--------
53+
54+
- Organize project documentation hierarchically (Project → Task → Wiki)
55+
- Keep documentation close to the work context (tasks)
56+
- Avoid inconsistencies between projects and tasks through automatic
57+
validations
58+
- Quickly access documentation related to a specific task
59+
60+
Dependencies
61+
------------
62+
63+
This module requires:
64+
65+
- ``document_page_project``: Module that links document pages to
66+
projects
67+
- ``project``: Odoo's project management module
68+
69+
**Table of contents**
70+
71+
.. contents::
72+
:local:
73+
74+
Configuration
75+
=============
76+
77+
Configuration
78+
=============
79+
80+
This module does not require additional configuration after
81+
installation. It works automatically once installed.
82+
83+
Installation
84+
------------
85+
86+
1. Go to the **Apps** menu
87+
2. Remove the "Apps" filter if necessary
88+
3. Search for "Document Page Project Task"
89+
4. Click **Install**
90+
91+
Prerequisites
92+
-------------
93+
94+
Make sure the following modules are installed:
95+
96+
- **Project** (base project module)
97+
- **Document Page Project** (links wiki pages to projects)
98+
99+
The system will automatically install the necessary dependencies during
100+
installation.
101+
102+
Permissions
103+
-----------
104+
105+
The module uses the same access permissions as the base modules:
106+
107+
- Users with access to **Projects** can view and create wiki pages
108+
linked to tasks
109+
- Users with access to **Documents/Knowledge** can manage wiki page
110+
content
111+
112+
No additional permission configuration is required.
113+
114+
Usage
115+
=====
116+
117+
How to Use
118+
==========
119+
120+
This guide explains how to use the Document Page Project Task module to
121+
link wiki pages to project tasks.
122+
123+
Create a Wiki Page from a Task
124+
------------------------------
125+
126+
Method 1: From the Task
127+
~~~~~~~~~~~~~~~~~~~~~~~
128+
129+
1. Go to the **Projects** module
130+
2. Open the desired project
131+
3. Select a task
132+
4. In the task view, locate the **Wiki Pages** button (book icon)
133+
5. Click the button to see linked pages or create a new one
134+
6. Click **Create** to add a new wiki page
135+
7. The task and project will be automatically filled
136+
137+
Method 2: From the Wiki Page
138+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
139+
140+
1. Go to the **Knowledge** or **Documents** module
141+
2. Create a new wiki page or edit an existing one
142+
3. In the page form, you will see the fields:
143+
144+
- **Project**: Select the project
145+
- **Task**: Select the task (only tasks from the selected project
146+
will be displayed)
147+
148+
4. When you select a task, the project will be automatically filled
149+
5. Save the page
150+
151+
Automatic Behaviors
152+
-------------------
153+
154+
Automatic Project Filling
155+
~~~~~~~~~~~~~~~~~~~~~~~~~
156+
157+
When you select a task:
158+
159+
- The **Project** field is automatically filled with the task's project
160+
- This ensures consistency between task and project
161+
162+
Task Filtering
163+
~~~~~~~~~~~~~~
164+
165+
When a project is selected:
166+
167+
- Only tasks from that project appear in the selection list
168+
- This prevents selecting tasks from different projects
169+
170+
Consistency Validation
171+
~~~~~~~~~~~~~~~~~~~~~~
172+
173+
The system automatically validates that:
174+
175+
- If a task is linked, the project must also be defined
176+
- The wiki page's project must be the same as the linked task's project
177+
- If you try to link a task to a different project, the system will
178+
prevent the operation
179+
180+
Automatic Cleanup
181+
~~~~~~~~~~~~~~~~~
182+
183+
When you change the project:
184+
185+
- If the linked task does not belong to the new project, it is
186+
automatically removed
187+
- This maintains data consistency
188+
189+
View Wiki Pages of a Task
190+
-------------------------
191+
192+
1. Access a project task
193+
2. At the top of the form, you will see the **Wiki Pages** button with a
194+
counter
195+
3. The displayed number indicates how many wiki pages are linked to the
196+
task
197+
4. Click the button to see all linked pages
198+
199+
Usage Examples
200+
--------------
201+
202+
Example 1: Requirements Documentation
203+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
204+
205+
1. Create a task "Define System Requirements"
206+
2. From the task, create a wiki page "Functional Requirements"
207+
3. Document the requirements in the wiki page
208+
4. The page will be linked to the task and project
209+
210+
Example 2: Meeting Notes
211+
~~~~~~~~~~~~~~~~~~~~~~~~
212+
213+
1. Create a task "Planning Meeting"
214+
2. Create a wiki page "Meeting Minutes"
215+
3. Document the discussed points
216+
4. The documentation will be organized and easy to find
217+
218+
Example 3: Technical Specifications
219+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
220+
221+
1. Create a task "Develop Module X"
222+
2. Create a wiki page "Technical Specification"
223+
3. Document the architecture and technical decisions
224+
4. Keep the documentation close to the task work
225+
226+
Tips
227+
----
228+
229+
- Use wiki pages to maintain contextual documentation related to
230+
specific tasks
231+
- The page counter on the task helps quickly identify tasks with
232+
documentation
233+
- When creating a page from the task, fields are automatically filled,
234+
saving time
235+
- Organize project documentation hierarchically: Project → Task → Wiki
236+
237+
Bug Tracker
238+
===========
239+
240+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/knowledge/issues>`_.
241+
In case of trouble, please check there if your issue has already been reported.
242+
If you spotted it first, help us to smash it by providing a detailed and welcomed
243+
`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**>`_.
244+
245+
Do not contact contributors directly about support or help with technical issues.
246+
247+
Credits
248+
=======
249+
250+
Authors
251+
-------
252+
253+
* Escodoo
254+
255+
Contributors
256+
------------
257+
258+
- `ESCODOO <https://escodoo.com.br>`__:
259+
260+
- Marcel Savegnago <marcel.savegnago@escodoo.com.br>
261+
262+
Maintainers
263+
-----------
264+
265+
This module is maintained by the OCA.
266+
267+
.. image:: https://odoo-community.org/logo.png
268+
:alt: Odoo Community Association
269+
:target: https://odoo-community.org
270+
271+
OCA, or the Odoo Community Association, is a nonprofit organization whose
272+
mission is to support the collaborative development of Odoo features and
273+
promote its widespread use.
274+
275+
.. |maintainer-marcelsavegnago| image:: https://github.com/marcelsavegnago.png?size=40px
276+
:target: https://github.com/marcelsavegnago
277+
:alt: marcelsavegnago
278+
279+
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
280+
281+
|maintainer-marcelsavegnago|
282+
283+
This module is part of the `OCA/knowledge <https://github.com/OCA/knowledge/tree/16.0/document_page_project_task>`_ project on GitHub.
284+
285+
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: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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 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+
def _compute_document_page_count(self):
16+
for rec in self:
17+
rec.document_page_count = len(rec.document_page_ids)

0 commit comments

Comments
 (0)