Skip to content

Commit 526c6ab

Browse files
[ADD] project_task_name_with_id
1 parent d7b897b commit 526c6ab

File tree

12 files changed

+594
-0
lines changed

12 files changed

+594
-0
lines changed

project_task_name_with_id/README.rst

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
=========================
2+
Project Task Name with ID
3+
=========================
4+
5+
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6+
!! This file is generated by oca-gen-addon-readme !!
7+
!! changes will be overwritten. !!
8+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
9+
10+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
11+
:target: https://odoo-community.org/page/development-status
12+
:alt: Beta
13+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
14+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
15+
:alt: License: AGPL-3
16+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fproject-lightgray.png?logo=github
17+
:target: https://github.com/OCA/project/tree/16.0/project_task_name_with_id
18+
:alt: OCA/project
19+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
20+
:target: https://translation.odoo-community.org/projects/project-16-0/project-16-0-project_task_name_with_id
21+
:alt: Translate me on Weblate
22+
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
23+
:target: https://runbot.odoo-community.org/runbot/140/16.0
24+
:alt: Try me on Runbot
25+
26+
|badge1| |badge2| |badge3| |badge4| |badge5|
27+
28+
This module extends the name_search() and name_get() methods of the project.task model
29+
to search for, and display the ID of the task in the name field.
30+
31+
This module will simplify your operations if they heavily rely on the task ID. For
32+
instance, you can select a task by its ID when creating a timesheet record.
33+
34+
**Table of contents**
35+
36+
.. contents::
37+
:local:
38+
39+
Usage
40+
=====
41+
42+
To use this module, you need to:
43+
44+
#. Navigate to Project > My Tasks > Create a New Task.
45+
The task's display name will change to a concatenation of its ID and task name (e.g., [ID] task_name).
46+
#. You can search for the task using its ID in the Many2one field or in the search view.
47+
48+
Bug Tracker
49+
===========
50+
51+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/project/issues>`_.
52+
In case of trouble, please check there if your issue has already been reported.
53+
If you spotted it first, help us smashing it by providing a detailed and welcomed
54+
`feedback <https://github.com/OCA/project/issues/new?body=module:%20project_task_name_with_id%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
55+
56+
Do not contact contributors directly about support or help with technical issues.
57+
58+
Credits
59+
=======
60+
61+
Authors
62+
~~~~~~~
63+
64+
* Quartile Limited
65+
66+
Maintainers
67+
~~~~~~~~~~~
68+
69+
This module is maintained by the OCA.
70+
71+
.. image:: https://odoo-community.org/logo.png
72+
:alt: Odoo Community Association
73+
:target: https://odoo-community.org
74+
75+
OCA, or the Odoo Community Association, is a nonprofit organization whose
76+
mission is to support the collaborative development of Odoo features and
77+
promote its widespread use.
78+
79+
This module is part of the `OCA/project <https://github.com/OCA/project/tree/16.0/project_task_name_with_id>`_ project on GitHub.
80+
81+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

project_task_name_with_id/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright 2023 Quartile Limited
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
{
4+
"name": "Project Task Name with ID",
5+
"category": "Project",
6+
"version": "16.0.1.0.0",
7+
"author": "Quartile Limited, Odoo Community Association (OCA)",
8+
"website": "https://github.com/OCA/project",
9+
"license": "AGPL-3",
10+
"depends": ["project"],
11+
"installable": True,
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import project_task
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright 2023 Quartile Limited
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from odoo import api, models
5+
6+
7+
class ProjectTask(models.Model):
8+
_inherit = "project.task"
9+
10+
@api.model
11+
def name_search(self, name, args=None, operator="ilike", limit=100):
12+
recs = self.search(
13+
["|", ("name", operator, name), ("id", operator, name)], limit=limit
14+
)
15+
return recs.name_get()
16+
17+
def name_get(self):
18+
result = super().name_get()
19+
new_result = []
20+
for task in result:
21+
rec = self.browse(task[0])
22+
name = "[{}] {}".format(rec.id, task[1])
23+
new_result.append((rec.id, name))
24+
return new_result
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
This module extends the name_search() and name_get() methods of the project.task model
2+
to search for, and display the ID of the task in the name field.
3+
4+
This module will simplify your operations if they heavily rely on the task ID. For
5+
instance, you can select a task by its ID when creating a timesheet record.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
To use this module, you need to:
2+
3+
#. Navigate to Project > My Tasks > Create a New Task.
4+
The task's display name will change to a concatenation of its ID and task name (e.g., [ID] task_name).
5+
#. You can search for the task using its ID in the Many2one field or in the search view.

0 commit comments

Comments
 (0)