diff --git a/project_task_name_with_id/README.rst b/project_task_name_with_id/README.rst new file mode 100644 index 0000000000..9eaa54c3d2 --- /dev/null +++ b/project_task_name_with_id/README.rst @@ -0,0 +1,97 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +========================= +Project Task Name with ID +========================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:5180287a1ce53ba3eb560ab3322d2059df11868e185030459bb0c7357eb64b77 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fproject-lightgray.png?logo=github + :target: https://github.com/OCA/project/tree/19.0/project_task_name_with_id + :alt: OCA/project +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/project-19-0/project-19-0-project_task_name_with_id + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/project&target_branch=19.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends the name_search() and name_get() methods of the +project.task model to search for, and display the ID of the task in the +name field. + +This module will simplify your operations if they heavily rely on the +task ID. For instance, you can select a task by its ID when creating a +timesheet record. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +The task's display name will change to a concatenation of its ID and +task name (e.g., [ID] task_name). You can search for the task using its +ID in the Many2one field or in the search view. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Quartile + +Contributors +------------ + +- `Quartile `__: + + - Yoshi Tashiro + +- Miquel Pascual + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/project `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/project_task_name_with_id/__init__.py b/project_task_name_with_id/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/project_task_name_with_id/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/project_task_name_with_id/__manifest__.py b/project_task_name_with_id/__manifest__.py new file mode 100644 index 0000000000..362fc9b5e1 --- /dev/null +++ b/project_task_name_with_id/__manifest__.py @@ -0,0 +1,13 @@ +# Copyright 2023 Quartile (https://www.quartile.co) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Project Task Name with ID", + "category": "Project", + "version": "19.0.1.0.0", + "author": "Quartile, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/project", + "license": "AGPL-3", + "depends": ["project"], + "data": ["views/project_task_views.xml"], + "installable": True, +} diff --git a/project_task_name_with_id/i18n/it.po b/project_task_name_with_id/i18n/it.po new file mode 100644 index 0000000000..72c417cf17 --- /dev/null +++ b/project_task_name_with_id/i18n/it.po @@ -0,0 +1,22 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * project_task_name_with_id +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-04-19 11:41+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: project_task_name_with_id +#: model:ir.model,name:project_task_name_with_id.model_project_task +msgid "Task" +msgstr "Lavoro" diff --git a/project_task_name_with_id/i18n/project_task_name_with_id.pot b/project_task_name_with_id/i18n/project_task_name_with_id.pot new file mode 100644 index 0000000000..11e64f97eb --- /dev/null +++ b/project_task_name_with_id/i18n/project_task_name_with_id.pot @@ -0,0 +1,19 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * project_task_name_with_id +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: project_task_name_with_id +#: model:ir.model,name:project_task_name_with_id.model_project_task +msgid "Task" +msgstr "" diff --git a/project_task_name_with_id/models/__init__.py b/project_task_name_with_id/models/__init__.py new file mode 100644 index 0000000000..edf2d36b9c --- /dev/null +++ b/project_task_name_with_id/models/__init__.py @@ -0,0 +1 @@ +from . import project_task diff --git a/project_task_name_with_id/models/project_task.py b/project_task_name_with_id/models/project_task.py new file mode 100644 index 0000000000..a79a924e11 --- /dev/null +++ b/project_task_name_with_id/models/project_task.py @@ -0,0 +1,27 @@ +# Copyright 2023 Quartile (https://www.quartile.co) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, models +from odoo.fields import Domain + + +class ProjectTask(models.Model): + _inherit = "project.task" + + @api.depends("name") + def _compute_display_name(self): + super()._compute_display_name() + for task in self: + if not task.id: + continue + task.display_name = f"[{task.id}] {task.display_name}" + return + + @api.model + def name_search(self, name="", args=None, operator="ilike", limit=100): + args = args or [] + domain = Domain.AND( + [args, ["|", ("name", operator, name), ("id", operator, name)]] + ) + records = self.search(domain, limit=limit) + return [(rec.id, rec.display_name or "") for rec in records] diff --git a/project_task_name_with_id/pyproject.toml b/project_task_name_with_id/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/project_task_name_with_id/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/project_task_name_with_id/readme/CONTRIBUTORS.md b/project_task_name_with_id/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..1b2b2b22b2 --- /dev/null +++ b/project_task_name_with_id/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- [Quartile](https://www.quartile.co): + - Yoshi Tashiro +- Miquel Pascual \<\> diff --git a/project_task_name_with_id/readme/DESCRIPTION.md b/project_task_name_with_id/readme/DESCRIPTION.md new file mode 100644 index 0000000000..5210ecf926 --- /dev/null +++ b/project_task_name_with_id/readme/DESCRIPTION.md @@ -0,0 +1,7 @@ +This module extends the name_search() and name_get() methods of the +project.task model to search for, and display the ID of the task in the +name field. + +This module will simplify your operations if they heavily rely on the +task ID. For instance, you can select a task by its ID when creating a +timesheet record. diff --git a/project_task_name_with_id/readme/USAGE.md b/project_task_name_with_id/readme/USAGE.md new file mode 100644 index 0000000000..76f93b803a --- /dev/null +++ b/project_task_name_with_id/readme/USAGE.md @@ -0,0 +1,3 @@ +The task's display name will change to a concatenation of its ID and +task name (e.g., \[ID\] task_name). You can search for the task using +its ID in the Many2one field or in the search view. diff --git a/project_task_name_with_id/static/description/icon.png b/project_task_name_with_id/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/project_task_name_with_id/static/description/icon.png differ diff --git a/project_task_name_with_id/static/description/index.html b/project_task_name_with_id/static/description/index.html new file mode 100644 index 0000000000..073c91e71e --- /dev/null +++ b/project_task_name_with_id/static/description/index.html @@ -0,0 +1,445 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Project Task Name with ID

+ +

Beta License: AGPL-3 OCA/project Translate me on Weblate Try me on Runboat

+

This module extends the name_search() and name_get() methods of the +project.task model to search for, and display the ID of the task in the +name field.

+

This module will simplify your operations if they heavily rely on the +task ID. For instance, you can select a task by its ID when creating a +timesheet record.

+

Table of contents

+ +
+

Usage

+

The task’s display name will change to a concatenation of its ID and +task name (e.g., [ID] task_name). You can search for the task using its +ID in the Many2one field or in the search view.

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Quartile
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/project project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+
+ + diff --git a/project_task_name_with_id/tests/__init__.py b/project_task_name_with_id/tests/__init__.py new file mode 100644 index 0000000000..ea27e1fc5d --- /dev/null +++ b/project_task_name_with_id/tests/__init__.py @@ -0,0 +1 @@ +from . import test_project_task_id diff --git a/project_task_name_with_id/tests/test_project_task_id.py b/project_task_name_with_id/tests/test_project_task_id.py new file mode 100644 index 0000000000..bee6bb19ea --- /dev/null +++ b/project_task_name_with_id/tests/test_project_task_id.py @@ -0,0 +1,36 @@ +# Copyright 2023 Quartile Limited +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +import re + +from odoo.tests.common import TransactionCase + + +class TestProjectTaskID(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.ProjectTask = cls.env["project.task"] + cls.project_task = cls.ProjectTask.create( + { + "name": "Test task", + } + ) + + def test_name_search(self): + # Test searching by name + tasks = self.ProjectTask.name_search("Test task") + self.assertEqual(len(tasks), 1) + self.assertEqual(tasks[0][0], self.project_task.id) + + # Test searching by ID + tasks = self.ProjectTask.name_search(str(self.project_task.id)) + self.assertEqual(len(tasks), 1) + self.assertEqual(tasks[0][0], self.project_task.id) + + def test_display_name(self): + display_name = self.project_task.display_name + task_id = self.project_task.id + # Checking for the task ID and "Test task" anywhere in the string + pattern = re.compile(rf"\[{task_id}\].*Test task") + self.assertTrue(pattern.search(display_name)) diff --git a/project_task_name_with_id/views/project_task_views.xml b/project_task_name_with_id/views/project_task_views.xml new file mode 100644 index 0000000000..59c8c67f53 --- /dev/null +++ b/project_task_name_with_id/views/project_task_views.xml @@ -0,0 +1,84 @@ + + + + project.task.tree + project.task + + + + show + + + + + project.task.kanban + project.task + + + + + 1 + + + + + + + + + + + + + + + + + + + project.sharing.project.task.tree + project.task + + + + + + + + + project.sharing.project.task.view.kanban + project.task + + + + + 1 + + + + + + + + + + + + + + + project.task.search.form + project.task + + + + ['|', ('name', 'ilike', self), ('id', 'ilike', self)] + + + +