diff --git a/project_analytic_code/README.rst b/project_analytic_code/README.rst new file mode 100644 index 0000000000..a0e11dd315 --- /dev/null +++ b/project_analytic_code/README.rst @@ -0,0 +1,90 @@ +===================== +Project analytic code +===================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:f2515ed6acc3794b02fc29bfc90b4fbf96a7765ad748f26cf183f42ee706c907 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/licence-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/18.0/project_analytic_code + :alt: OCA/project +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/project-18-0/project-18-0-project_analytic_code + :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=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module add related Analytic account code ( related field +analytic_account_code) on project model. + +The name of the project in related model display the analytic account +code (using name_get) and you can search projects by the analytic +account code (name_search) from any list ( ie: collecting timesheets). + +Add analytic account code in project kanban card view and add group by +and search by account analytic. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +Once this module is installed you can search project per analytic +account code from any list that point to a project (name search). + +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 +------- + +* Pierre Verkest + +Contributors +------------ + +- Pierre Verkest + +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_analytic_code/__init__.py b/project_analytic_code/__init__.py new file mode 100644 index 0000000000..cb45f2710a --- /dev/null +++ b/project_analytic_code/__init__.py @@ -0,0 +1,2 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from . import models diff --git a/project_analytic_code/__manifest__.py b/project_analytic_code/__manifest__.py new file mode 100644 index 0000000000..0624202c46 --- /dev/null +++ b/project_analytic_code/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright 2021 Pierre Verkest +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "Project analytic code", + "summary": "Search projects by analytic account code.", + "author": "Pierre Verkest, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/project", + "category": "Project Management", + "version": "18.0.0.1.0", + "license": "AGPL-3", + "depends": [ + "project", + ], + "data": [ + "views/project.xml", + ], +} diff --git a/project_analytic_code/i18n/fr.po b/project_analytic_code/i18n/fr.po new file mode 100644 index 0000000000..8a749bfdf1 --- /dev/null +++ b/project_analytic_code/i18n/fr.po @@ -0,0 +1,45 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * project_analytic_code +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: project_analytic_code +#: model_terms:ir.ui.view,arch_db:project_analytic_code.view_project_project_filter +msgid "Analytic account" +msgstr "Compte analytique" + +#. module: project_analytic_code +#: model:ir.model.fields,field_description:project_analytic_code.field_project_project__analytic_account_code +msgid "Analytic code" +msgstr "Code analytique" + +#. module: project_analytic_code +#: model:ir.model.fields,field_description:project_analytic_code.field_project_project__display_name +msgid "Display Name" +msgstr "Libellé" + +#. module: project_analytic_code +#: model:ir.model.fields,field_description:project_analytic_code.field_project_project__id +msgid "ID" +msgstr "" + +#. module: project_analytic_code +#: model:ir.model.fields,field_description:project_analytic_code.field_project_project____last_update +msgid "Last Modified on" +msgstr "Dernière modification le" + +#. module: project_analytic_code +#: model:ir.model,name:project_analytic_code.model_project_project +msgid "Project" +msgstr "Projet" diff --git a/project_analytic_code/i18n/it.po b/project_analytic_code/i18n/it.po new file mode 100644 index 0000000000..6943c20904 --- /dev/null +++ b/project_analytic_code/i18n/it.po @@ -0,0 +1,32 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * project_analytic_code +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2025-12-20 09:42+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 5.10.4\n" + +#. module: project_analytic_code +#: model_terms:ir.ui.view,arch_db:project_analytic_code.view_project_project_filter +msgid "Analytic account" +msgstr "Conto analitico" + +#. module: project_analytic_code +#: model:ir.model.fields,field_description:project_analytic_code.field_project_project__analytic_account_code +msgid "Analytic code" +msgstr "Codice analitico" + +#. module: project_analytic_code +#: model:ir.model,name:project_analytic_code.model_project_project +msgid "Project" +msgstr "Progetto" diff --git a/project_analytic_code/i18n/project_analytic_code.pot b/project_analytic_code/i18n/project_analytic_code.pot new file mode 100644 index 0000000000..1768663250 --- /dev/null +++ b/project_analytic_code/i18n/project_analytic_code.pot @@ -0,0 +1,29 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * project_analytic_code +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.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_analytic_code +#: model_terms:ir.ui.view,arch_db:project_analytic_code.view_project_project_filter +msgid "Analytic account" +msgstr "" + +#. module: project_analytic_code +#: model:ir.model.fields,field_description:project_analytic_code.field_project_project__analytic_account_code +msgid "Analytic code" +msgstr "" + +#. module: project_analytic_code +#: model:ir.model,name:project_analytic_code.model_project_project +msgid "Project" +msgstr "" diff --git a/project_analytic_code/models/__init__.py b/project_analytic_code/models/__init__.py new file mode 100644 index 0000000000..0364439211 --- /dev/null +++ b/project_analytic_code/models/__init__.py @@ -0,0 +1,2 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from . import project diff --git a/project_analytic_code/models/project.py b/project_analytic_code/models/project.py new file mode 100644 index 0000000000..7ffbbab5ba --- /dev/null +++ b/project_analytic_code/models/project.py @@ -0,0 +1,29 @@ +# Copyright 2021 Pierre Verkest +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import api, fields, models + + +class Project(models.Model): + _inherit = "project.project" + + _rec_names_search = [ + "name", + "analytic_account_code", + ] + + analytic_account_code = fields.Char( + string="Analytic code", + related="account_id.code", + store=True, + index="btree_not_null", + ) + + @api.depends("analytic_account_code") + def _compute_display_name(self): + res = super()._compute_display_name() + for project in self.filtered(lambda p: p.analytic_account_code): + project.display_name = ( + f"[{project.analytic_account_code}] {project.display_name}" + ) + return res diff --git a/project_analytic_code/pyproject.toml b/project_analytic_code/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/project_analytic_code/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/project_analytic_code/readme/CONTRIBUTORS.md b/project_analytic_code/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..926261edf6 --- /dev/null +++ b/project_analytic_code/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +- Pierre Verkest \<\> diff --git a/project_analytic_code/readme/DESCRIPTION.md b/project_analytic_code/readme/DESCRIPTION.md new file mode 100644 index 0000000000..7a1d59a29c --- /dev/null +++ b/project_analytic_code/readme/DESCRIPTION.md @@ -0,0 +1,9 @@ +This module add related Analytic account code ( related field +analytic_account_code) on project model. + +The name of the project in related model display the analytic account +code (using name_get) and you can search projects by the analytic +account code (name_search) from any list ( ie: collecting timesheets). + +Add analytic account code in project kanban card view and add group by +and search by account analytic. diff --git a/project_analytic_code/readme/USAGE.md b/project_analytic_code/readme/USAGE.md new file mode 100644 index 0000000000..c24ea7c57d --- /dev/null +++ b/project_analytic_code/readme/USAGE.md @@ -0,0 +1,2 @@ +Once this module is installed you can search project per analytic +account code from any list that point to a project (name search). diff --git a/project_analytic_code/static/description/icon.png b/project_analytic_code/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/project_analytic_code/static/description/icon.png differ diff --git a/project_analytic_code/static/description/index.html b/project_analytic_code/static/description/index.html new file mode 100644 index 0000000000..9bbd32997c --- /dev/null +++ b/project_analytic_code/static/description/index.html @@ -0,0 +1,435 @@ + + + + + +Project analytic code + + + +
+

Project analytic code

+ + +

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

+

This module add related Analytic account code ( related field +analytic_account_code) on project model.

+

The name of the project in related model display the analytic account +code (using name_get) and you can search projects by the analytic +account code (name_search) from any list ( ie: collecting timesheets).

+

Add analytic account code in project kanban card view and add group by +and search by account analytic.

+

Table of contents

+ +
+

Usage

+

Once this module is installed you can search project per analytic +account code from any list that point to a project (name search).

+
+
+

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

+
    +
  • Pierre Verkest
  • +
+
+
+

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_analytic_code/tests/__init__.py b/project_analytic_code/tests/__init__.py new file mode 100644 index 0000000000..1cb1c7f5b5 --- /dev/null +++ b/project_analytic_code/tests/__init__.py @@ -0,0 +1,3 @@ +# Copyright 2021 Pierre Verkest +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from . import test_project diff --git a/project_analytic_code/tests/test_project.py b/project_analytic_code/tests/test_project.py new file mode 100644 index 0000000000..0278b966fa --- /dev/null +++ b/project_analytic_code/tests/test_project.py @@ -0,0 +1,47 @@ +# Copyright 2021 Pierre Verkest +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo.tests import tagged +from odoo.tests.common import TransactionCase + + +@tagged("post_install", "-at_install") +class TestProject(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.project = cls.env.ref("project.project_project_1") + cls.project.name = "Test project name" + cls.plan = cls.env["account.analytic.plan"].create({"name": "Test plan"}) + cls.project.account_id = cls.env["account.analytic.account"].create( + { + "name": "Test Analytic account name", + "code": "Test Weird code", + "plan_id": cls.plan.id, + } + ) + cls.env.flush_all() + + def test_search_project_by_account_analytic_code(self): + self.env.flush_all() + result = self.env["project.project"].name_search( + name=self.project.account_id.code + ) + self.assertEqual( + result[0][1], + f"[{self.project.account_id.code}] {self.project.name}", + ) + + def test_project_display_name(self): + original_account = self.project.account_id + self.assertEqual( + self.project.display_name, + f"[{self.project.account_id.code}] {self.project.name}", + ) + self.project.account_id = False + + self.assertEqual( + self.project.display_name, + f"{self.project.name}", + ) + self.project.account_id = original_account diff --git a/project_analytic_code/views/project.xml b/project_analytic_code/views/project.xml new file mode 100644 index 0000000000..e63d75d9c3 --- /dev/null +++ b/project_analytic_code/views/project.xml @@ -0,0 +1,22 @@ + + + + + project_analytic_code.project.select + project.project + + + ["|", ("name", "ilike", self), ("analytic_account_code", "=", self)] + + + + + + +