diff --git a/hr_timesheet_task_domain/README.rst b/hr_timesheet_task_domain/README.rst new file mode 100644 index 000000000..de6b29cb1 --- /dev/null +++ b/hr_timesheet_task_domain/README.rst @@ -0,0 +1,91 @@ +=============================== +Task Log: limit Task by Project +=============================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Ftimesheet-lightgray.png?logo=github + :target: https://github.com/OCA/timesheet/tree/15.0/hr_timesheet_task_domain + :alt: OCA/timesheet +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/timesheet-14-0/timesheet-14-0-hr_timesheet_task_domain + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/117/15.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adjusts the domain applied to task field in order to limit task +selection to currently-selected project. If `project_stage_closed` module is +installed, also limits selection to tasks in any of "Open" stages in order to +accommodate a project flow. + +**Table of contents** + +.. contents:: + :local: + +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 smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Tecnativa +* CorporateHub + +Contributors +~~~~~~~~~~~~ + +* `Tecnativa `_: + + * Pedro M. Baeza + * Antonio Espinosa + * Carlos Dauden + * Sergio Teruel + * Luis M. ontalba + * Ernesto Tejeda + * Manuel Calero + +* `CorporateHub `__ + + * Alexey Pelykh + +* Foram Shah + +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/timesheet `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/hr_timesheet_task_domain/__init__.py b/hr_timesheet_task_domain/__init__.py new file mode 100644 index 000000000..4b76c7b2d --- /dev/null +++ b/hr_timesheet_task_domain/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import models diff --git a/hr_timesheet_task_domain/__manifest__.py b/hr_timesheet_task_domain/__manifest__.py new file mode 100644 index 000000000..94bad92a4 --- /dev/null +++ b/hr_timesheet_task_domain/__manifest__.py @@ -0,0 +1,21 @@ +# Copyright 2016 Tecnativa - Antonio Espinosa +# Copyright 2016 Tecnativa - Sergio Teruel +# Copyright 2016-2018 Tecnativa - Pedro M. Baeza +# Copyright 2018 Tecnativa - Ernesto Tejeda +# Copyright 2019 Brainbean Apps (https://brainbeanapps.com) +# Copyright 2020 Tecnativa - Manuel Calero +# Copyright 2020 CorporateHub (https://corporatehub.eu) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +{ + "name": "Task Log: limit Task by Project", + "version": "15.0.1.0.0", + "category": "Human Resources", + "website": "https://github.com/OCA/timesheet", + "author": "Tecnativa, CorporateHub, Odoo Community Association (OCA)", + "license": "AGPL-3", + "installable": True, + "application": False, + "summary": ("Limit task selection to tasks on currently-selected project"), + "depends": ["hr_timesheet"], +} diff --git a/hr_timesheet_task_domain/i18n/de.po b/hr_timesheet_task_domain/i18n/de.po new file mode 100644 index 000000000..ef5f729c9 --- /dev/null +++ b/hr_timesheet_task_domain/i18n/de.po @@ -0,0 +1,22 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * hr_timesheet_task_domain +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2019-07-11 12:43+0000\n" +"Last-Translator: Maria Sparenberg \n" +"Language-Team: none\n" +"Language: de\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 3.7.1\n" + +#. module: hr_timesheet_task_domain +#: model:ir.model,name:hr_timesheet_task_domain.model_account_analytic_line +msgid "Analytic Line" +msgstr "Kostenstellenbuchung" diff --git a/hr_timesheet_task_domain/i18n/es.po b/hr_timesheet_task_domain/i18n/es.po new file mode 100644 index 000000000..6392e40d4 --- /dev/null +++ b/hr_timesheet_task_domain/i18n/es.po @@ -0,0 +1,22 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * hr_timesheet_task_domain +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2019-07-11 12:43+0000\n" +"Last-Translator: Manuel Calero - Tecnativa\n" +"Language-Team: none\n" +"Language: de\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 3.7.1\n" + +#. module: hr_timesheet_task_domain +#: model:ir.model,name:hr_timesheet_task_domain.model_account_analytic_line +msgid "Analytic Line" +msgstr "Línea analítica" diff --git a/hr_timesheet_task_domain/i18n/fr.po b/hr_timesheet_task_domain/i18n/fr.po new file mode 100644 index 000000000..1272292d1 --- /dev/null +++ b/hr_timesheet_task_domain/i18n/fr.po @@ -0,0 +1,37 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * hr_timesheet_task_domain +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2022-05-10 11:05+0000\n" +"Last-Translator: Rémi \n" +"Language-Team: none\n" +"Language: fr\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.3.2\n" + +#. module: hr_timesheet_task_domain +#: model:ir.model,name:hr_timesheet_task_domain.model_account_analytic_line +msgid "Analytic Line" +msgstr "Ligne Analytique" + +#. module: hr_timesheet_task_domain +#: model:ir.model.fields,field_description:hr_timesheet_task_domain.field_account_analytic_line__display_name +msgid "Display Name" +msgstr "Nom Affiché" + +#. module: hr_timesheet_task_domain +#: model:ir.model.fields,field_description:hr_timesheet_task_domain.field_account_analytic_line__id +msgid "ID" +msgstr "" + +#. module: hr_timesheet_task_domain +#: model:ir.model.fields,field_description:hr_timesheet_task_domain.field_account_analytic_line____last_update +msgid "Last Modified on" +msgstr "Dernière modification le" diff --git a/hr_timesheet_task_domain/i18n/hr_timesheet_task_domain.pot b/hr_timesheet_task_domain/i18n/hr_timesheet_task_domain.pot new file mode 100644 index 000000000..014fb86df --- /dev/null +++ b/hr_timesheet_task_domain/i18n/hr_timesheet_task_domain.pot @@ -0,0 +1,34 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * hr_timesheet_task_domain +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.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: hr_timesheet_task_domain +#: model:ir.model,name:hr_timesheet_task_domain.model_account_analytic_line +msgid "Analytic Line" +msgstr "" + +#. module: hr_timesheet_task_domain +#: model:ir.model.fields,field_description:hr_timesheet_task_domain.field_account_analytic_line__display_name +msgid "Display Name" +msgstr "" + +#. module: hr_timesheet_task_domain +#: model:ir.model.fields,field_description:hr_timesheet_task_domain.field_account_analytic_line__id +msgid "ID" +msgstr "" + +#. module: hr_timesheet_task_domain +#: model:ir.model.fields,field_description:hr_timesheet_task_domain.field_account_analytic_line____last_update +msgid "Last Modified on" +msgstr "" diff --git a/hr_timesheet_task_domain/models/__init__.py b/hr_timesheet_task_domain/models/__init__.py new file mode 100644 index 000000000..977639646 --- /dev/null +++ b/hr_timesheet_task_domain/models/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import account_analytic_line diff --git a/hr_timesheet_task_domain/models/account_analytic_line.py b/hr_timesheet_task_domain/models/account_analytic_line.py new file mode 100644 index 000000000..f7481282b --- /dev/null +++ b/hr_timesheet_task_domain/models/account_analytic_line.py @@ -0,0 +1,31 @@ +# Copyright 2016 Tecnativa - Antonio Espinosa +# Copyright 2016 Tecnativa - Sergio Teruel +# Copyright 2016-2018 Tecnativa - Pedro M. Baeza +# Copyright 2019 Brainbean Apps (https://brainbeanapps.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, models + + +class AccountAnalyticLine(models.Model): + _inherit = "account.analytic.line" + + @api.onchange("project_id") + def _onchange_project_id(self): + task = self.task_id + res = super()._onchange_project_id() + if res is None: + res = {} + if self.project_id: # Show only opened tasks + task_domain = [ + ("project_id", "=", self.project_id.id), + ("stage_id.is_closed", "=", False), + ] + res_domain = res.setdefault("domain", {}) + res_domain.update({"task_id": task_domain}) + else: # Reset domain for allowing selection of any task + res["domain"] = {"task_id": []} + if task.project_id == self.project_id: + # Restore previous task if belongs to the same project + self.task_id = task + return res diff --git a/hr_timesheet_task_domain/readme/CONTRIBUTORS.rst b/hr_timesheet_task_domain/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..f2ddbc2fe --- /dev/null +++ b/hr_timesheet_task_domain/readme/CONTRIBUTORS.rst @@ -0,0 +1,15 @@ +* `Tecnativa `_: + + * Pedro M. Baeza + * Antonio Espinosa + * Carlos Dauden + * Sergio Teruel + * Luis M. ontalba + * Ernesto Tejeda + * Manuel Calero + +* `CorporateHub `__ + + * Alexey Pelykh + +* Foram Shah diff --git a/hr_timesheet_task_domain/readme/DESCRIPTION.rst b/hr_timesheet_task_domain/readme/DESCRIPTION.rst new file mode 100644 index 000000000..ec3ba360b --- /dev/null +++ b/hr_timesheet_task_domain/readme/DESCRIPTION.rst @@ -0,0 +1,4 @@ +This module adjusts the domain applied to task field in order to limit task +selection to currently-selected project. If `project_stage_closed` module is +installed, also limits selection to tasks in any of "Open" stages in order to +accommodate a project flow. diff --git a/hr_timesheet_task_domain/static/description/icon.png b/hr_timesheet_task_domain/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/hr_timesheet_task_domain/static/description/icon.png differ diff --git a/hr_timesheet_task_domain/static/description/index.html b/hr_timesheet_task_domain/static/description/index.html new file mode 100644 index 000000000..cc3e2c7a4 --- /dev/null +++ b/hr_timesheet_task_domain/static/description/index.html @@ -0,0 +1,442 @@ + + + + + + +Task Log: limit Task by Project + + + +
+

Task Log: limit Task by Project

+ + +

Beta License: AGPL-3 OCA/timesheet Translate me on Weblate Try me on Runbot

+

This module adjusts the domain applied to task field in order to limit task +selection to currently-selected project. If project_stage_closed module is +installed, also limits selection to tasks in any of “Open” stages in order to +accommodate a project flow.

+

Table of contents

+ +
+

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 smashing it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Tecnativa
  • +
  • CorporateHub
  • +
+
+
+

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/timesheet project on GitHub.

+

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

+
+
+
+ + diff --git a/hr_timesheet_task_domain/tests/__init__.py b/hr_timesheet_task_domain/tests/__init__.py new file mode 100644 index 000000000..047149c22 --- /dev/null +++ b/hr_timesheet_task_domain/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import test_hr_timesheet_task_domain diff --git a/hr_timesheet_task_domain/tests/test_hr_timesheet_task_domain.py b/hr_timesheet_task_domain/tests/test_hr_timesheet_task_domain.py new file mode 100644 index 000000000..5257fe00f --- /dev/null +++ b/hr_timesheet_task_domain/tests/test_hr_timesheet_task_domain.py @@ -0,0 +1,34 @@ +# Copyright 2016-2018 Tecnativa - Pedro M. Baeza +# Copyright 2019 Brainbean Apps (https://brainbeanapps.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo.tests import common + + +class TestHrTimesheetTaskDomain(common.TransactionCase): + def setUp(self): + super().setUp() + + self.project = self.env["project.project"].create({"name": "Test project"}) + self.analytic_account = self.project.analytic_account_id + self.task = self.env["project.task"].create( + {"name": "Test task", "project_id": self.project.id} + ) + self.line = self.env["account.analytic.line"].create( + { + "task_id": self.task.id, + "account_id": self.analytic_account.id, + "name": "Test line", + } + ) + + def test_onchange_project_id(self): + record = self.env["account.analytic.line"].new() + record.task_id = self.task.id + record.project_id = self.project.id + action = record._onchange_project_id() + self.assertTrue(action["domain"]["task_id"]) + self.assertEqual(record.task_id, self.task) + record.project_id = False + action = record._onchange_project_id() + self.assertEqual(action["domain"]["task_id"], []) diff --git a/setup/hr_timesheet_task_domain/odoo/addons/hr_timesheet_task_domain b/setup/hr_timesheet_task_domain/odoo/addons/hr_timesheet_task_domain new file mode 120000 index 000000000..f0e602a3b --- /dev/null +++ b/setup/hr_timesheet_task_domain/odoo/addons/hr_timesheet_task_domain @@ -0,0 +1 @@ +../../../../hr_timesheet_task_domain \ No newline at end of file diff --git a/setup/hr_timesheet_task_domain/setup.py b/setup/hr_timesheet_task_domain/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/hr_timesheet_task_domain/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)