Skip to content

Commit cfbcbe5

Browse files
[ADD] project_task_name_with_id
1 parent d7b897b commit cfbcbe5

File tree

12 files changed

+584
-0
lines changed

12 files changed

+584
-0
lines changed

project_task_name_with_id/README.rst

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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+
The task's display name will change to a concatenation of its ID and task name (e.g., [ID] task_name).
43+
You can search for the task using its ID in the Many2one field or in the search view.
44+
45+
Bug Tracker
46+
===========
47+
48+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/project/issues>`_.
49+
In case of trouble, please check there if your issue has already been reported.
50+
If you spotted it first, help us smashing it by providing a detailed and welcomed
51+
`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**>`_.
52+
53+
Do not contact contributors directly about support or help with technical issues.
54+
55+
Credits
56+
=======
57+
58+
Authors
59+
~~~~~~~
60+
61+
* Quartile Limited
62+
63+
Maintainers
64+
~~~~~~~~~~~
65+
66+
This module is maintained by the OCA.
67+
68+
.. image:: https://odoo-community.org/logo.png
69+
:alt: Odoo Community Association
70+
:target: https://odoo-community.org
71+
72+
OCA, or the Odoo Community Association, is a nonprofit organization whose
73+
mission is to support the collaborative development of Odoo features and
74+
promote its widespread use.
75+
76+
This module is part of the `OCA/project <https://github.com/OCA/project/tree/16.0/project_task_name_with_id>`_ project on GitHub.
77+
78+
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,2 @@
1+
The task's display name will change to a concatenation of its ID and task name (e.g., [ID] task_name).
2+
You can search for the task using its ID in the Many2one field or in the search view.

0 commit comments

Comments
 (0)