diff --git a/project_duplicate_subtask/README.rst b/project_duplicate_subtask/README.rst new file mode 100644 index 0000000000..ba2dd0c24c --- /dev/null +++ b/project_duplicate_subtask/README.rst @@ -0,0 +1,87 @@ +========================= +Project Duplicate subtask +========================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:9195c3a0abcc8cbaf20022734c176f28ee32489ccffcf83c459e0c01fe97028b + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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_duplicate_subtask + :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_duplicate_subtask + :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 adds a server action that allows to duplicate a task with +its child tasks. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use this module, there are two ways: + +1. Go to a task: Action > Duplicate with subtasks. +2. Go to the tasks list view, select the tasks you want to duplicate: + Action > Duplicate with subtasks. + +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 +------- + +* Forgeflow + +Contributors +------------ + +- Mateu Griful +- Lois Rilo + +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_duplicate_subtask/__init__.py b/project_duplicate_subtask/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/project_duplicate_subtask/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/project_duplicate_subtask/__manifest__.py b/project_duplicate_subtask/__manifest__.py new file mode 100644 index 0000000000..1d0b5299ec --- /dev/null +++ b/project_duplicate_subtask/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright (C) 2022 ForgeFlow S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) + +{ + "name": "Project Duplicate subtask", + "version": "18.0.1.0.0", + "category": "Project", + "website": "https://github.com/OCA/project", + "summary": "The module adds an action to duplicate tasks with the child subtasks", + "author": "Forgeflow, Odoo Community Association (OCA)", + "license": "AGPL-3", + "depends": ["project"], + "data": ["views/project_duplicate_action.xml"], + "installable": True, + "auto_install": False, +} diff --git a/project_duplicate_subtask/i18n/es.po b/project_duplicate_subtask/i18n/es.po new file mode 100644 index 0000000000..7ca7b2a683 --- /dev/null +++ b/project_duplicate_subtask/i18n/es.po @@ -0,0 +1,27 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * project_duplicate_subtask +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-09-07 16:36+0000\n" +"Last-Translator: Ivorra78 \n" +"Language-Team: none\n" +"Language: es\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_duplicate_subtask +#: model:ir.actions.server,name:project_duplicate_subtask.action_server_duplicate_subtasks +msgid "Duplicate with subtasks" +msgstr "Duplicar con subtareas" + +#. module: project_duplicate_subtask +#: model:ir.model,name:project_duplicate_subtask.model_project_task +msgid "Task" +msgstr "Tarea" diff --git a/project_duplicate_subtask/i18n/gl.po b/project_duplicate_subtask/i18n/gl.po new file mode 100644 index 0000000000..130f336037 --- /dev/null +++ b/project_duplicate_subtask/i18n/gl.po @@ -0,0 +1,27 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * project_duplicate_subtask +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2026-05-23 18:47+0000\n" +"Last-Translator: Pablo Castelo \n" +"Language-Team: none\n" +"Language: gl\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.15.2\n" + +#. module: project_duplicate_subtask +#: model:ir.actions.server,name:project_duplicate_subtask.action_server_duplicate_subtasks +msgid "Duplicate with subtasks" +msgstr "Duplicar con subtareas" + +#. module: project_duplicate_subtask +#: model:ir.model,name:project_duplicate_subtask.model_project_task +msgid "Task" +msgstr "Tarefa" diff --git a/project_duplicate_subtask/i18n/hr.po b/project_duplicate_subtask/i18n/hr.po new file mode 100644 index 0000000000..ac56682493 --- /dev/null +++ b/project_duplicate_subtask/i18n/hr.po @@ -0,0 +1,28 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * project_duplicate_subtask +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-06-18 11:59+0000\n" +"Last-Translator: Bole \n" +"Language-Team: none\n" +"Language: hr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && " +"n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" +"X-Generator: Weblate 4.17\n" + +#. module: project_duplicate_subtask +#: model:ir.actions.server,name:project_duplicate_subtask.action_server_duplicate_subtasks +msgid "Duplicate with subtasks" +msgstr "Dupliciraj sa podzadacima" + +#. module: project_duplicate_subtask +#: model:ir.model,name:project_duplicate_subtask.model_project_task +msgid "Task" +msgstr "Zadatak" diff --git a/project_duplicate_subtask/i18n/it.po b/project_duplicate_subtask/i18n/it.po new file mode 100644 index 0000000000..62cb125859 --- /dev/null +++ b/project_duplicate_subtask/i18n/it.po @@ -0,0 +1,27 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * project_duplicate_subtask +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-07-31 10:11+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_duplicate_subtask +#: model:ir.actions.server,name:project_duplicate_subtask.action_server_duplicate_subtasks +msgid "Duplicate with subtasks" +msgstr "Duplica con sottolavori" + +#. module: project_duplicate_subtask +#: model:ir.model,name:project_duplicate_subtask.model_project_task +msgid "Task" +msgstr "Lavoro" diff --git a/project_duplicate_subtask/i18n/project_duplicate_subtask.pot b/project_duplicate_subtask/i18n/project_duplicate_subtask.pot new file mode 100644 index 0000000000..22e930cec7 --- /dev/null +++ b/project_duplicate_subtask/i18n/project_duplicate_subtask.pot @@ -0,0 +1,24 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * project_duplicate_subtask +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.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_duplicate_subtask +#: model:ir.actions.server,name:project_duplicate_subtask.action_server_duplicate_subtasks +msgid "Duplicate with subtasks" +msgstr "" + +#. module: project_duplicate_subtask +#: model:ir.model,name:project_duplicate_subtask.model_project_task +msgid "Task" +msgstr "" diff --git a/project_duplicate_subtask/i18n/pt.po b/project_duplicate_subtask/i18n/pt.po new file mode 100644 index 0000000000..41a59783dc --- /dev/null +++ b/project_duplicate_subtask/i18n/pt.po @@ -0,0 +1,27 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * project_duplicate_subtask +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2025-02-07 18:26+0000\n" +"Last-Translator: Peter Romão \n" +"Language-Team: none\n" +"Language: pt\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.6.2\n" + +#. module: project_duplicate_subtask +#: model:ir.actions.server,name:project_duplicate_subtask.action_server_duplicate_subtasks +msgid "Duplicate with subtasks" +msgstr "Duplicar com subtarefas" + +#. module: project_duplicate_subtask +#: model:ir.model,name:project_duplicate_subtask.model_project_task +msgid "Task" +msgstr "Tarefa" diff --git a/project_duplicate_subtask/i18n/pt_BR.po b/project_duplicate_subtask/i18n/pt_BR.po new file mode 100644 index 0000000000..1cf244eb83 --- /dev/null +++ b/project_duplicate_subtask/i18n/pt_BR.po @@ -0,0 +1,27 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * project_duplicate_subtask +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-10-09 02:52+0000\n" +"Last-Translator: Adriano Prado \n" +"Language-Team: none\n" +"Language: pt_BR\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_duplicate_subtask +#: model:ir.actions.server,name:project_duplicate_subtask.action_server_duplicate_subtasks +msgid "Duplicate with subtasks" +msgstr "Duplicar com Subtarefas" + +#. module: project_duplicate_subtask +#: model:ir.model,name:project_duplicate_subtask.model_project_task +msgid "Task" +msgstr "Tarefa" diff --git a/project_duplicate_subtask/models/__init__.py b/project_duplicate_subtask/models/__init__.py new file mode 100644 index 0000000000..edf2d36b9c --- /dev/null +++ b/project_duplicate_subtask/models/__init__.py @@ -0,0 +1 @@ +from . import project_task diff --git a/project_duplicate_subtask/models/project_task.py b/project_duplicate_subtask/models/project_task.py new file mode 100644 index 0000000000..0e5128ba76 --- /dev/null +++ b/project_duplicate_subtask/models/project_task.py @@ -0,0 +1,39 @@ +# Copyright (C) 2022 ForgeFlow S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) + +from odoo import models + + +class ProjectTask(models.Model): + _inherit = "project.task" + + def action_duplicate_subtasks(self): + action = self.env.ref("project.action_view_task") + result = action.read()[0] + task_created = self.env["project.task"] + for task in self: + new_task = task.copy() + task_created |= new_task + if task.child_ids: + + def duplicate_childs(task, new_task): + if task.child_ids: + for child in task.child_ids: + new_subtask = child.copy() + new_subtask.write({"parent_id": new_task.id}) + duplicate_childs(child, new_subtask) + + duplicate_childs(task, new_task) + + if len(task_created) == 1: + res = self.env.ref("project.view_task_form2") + result["views"] = [(res and res.id or False, "form")] + result["res_id"] = new_task.id + action["context"] = { + "form_view_initial_mode": "edit", + "force_detailed_view": "true", + } + + else: + result["domain"] = "[('id', 'in', " + str(task_created.ids) + ")]" + return result diff --git a/project_duplicate_subtask/pyproject.toml b/project_duplicate_subtask/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/project_duplicate_subtask/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/project_duplicate_subtask/readme/CONTRIBUTORS.md b/project_duplicate_subtask/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..ec3dfeec24 --- /dev/null +++ b/project_duplicate_subtask/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- Mateu Griful \<\> +- Lois Rilo \<\> diff --git a/project_duplicate_subtask/readme/DESCRIPTION.md b/project_duplicate_subtask/readme/DESCRIPTION.md new file mode 100644 index 0000000000..d47cf52f9d --- /dev/null +++ b/project_duplicate_subtask/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module adds a server action that allows to duplicate a task with its +child tasks. diff --git a/project_duplicate_subtask/readme/USAGE.md b/project_duplicate_subtask/readme/USAGE.md new file mode 100644 index 0000000000..ae17951fd6 --- /dev/null +++ b/project_duplicate_subtask/readme/USAGE.md @@ -0,0 +1,5 @@ +To use this module, there are two ways: + +1. Go to a task: Action \> Duplicate with subtasks. +2. Go to the tasks list view, select the tasks you want to duplicate: + Action \> Duplicate with subtasks. diff --git a/project_duplicate_subtask/static/description/icon.png b/project_duplicate_subtask/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/project_duplicate_subtask/static/description/icon.png differ diff --git a/project_duplicate_subtask/static/description/index.html b/project_duplicate_subtask/static/description/index.html new file mode 100644 index 0000000000..2b6d982fab --- /dev/null +++ b/project_duplicate_subtask/static/description/index.html @@ -0,0 +1,435 @@ + + + + + +Project Duplicate subtask + + + +
+

Project Duplicate subtask

+ + +

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

+

This module adds a server action that allows to duplicate a task with +its child tasks.

+

Table of contents

+ +
+

Usage

+

To use this module, there are two ways:

+
    +
  1. Go to a task: Action > Duplicate with subtasks.
  2. +
  3. Go to the tasks list view, select the tasks you want to duplicate: +Action > Duplicate with subtasks.
  4. +
+
+
+

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

+
    +
  • Forgeflow
  • +
+
+ +
+

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_duplicate_subtask/tests/__init__.py b/project_duplicate_subtask/tests/__init__.py new file mode 100644 index 0000000000..6a30cf048b --- /dev/null +++ b/project_duplicate_subtask/tests/__init__.py @@ -0,0 +1 @@ +from . import test_project_duplicate_subtask diff --git a/project_duplicate_subtask/tests/test_project_duplicate_subtask.py b/project_duplicate_subtask/tests/test_project_duplicate_subtask.py new file mode 100644 index 0000000000..5172b4e749 --- /dev/null +++ b/project_duplicate_subtask/tests/test_project_duplicate_subtask.py @@ -0,0 +1,51 @@ +# Copyright (C) 2021 ForgeFlow S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) + +from odoo.tests.common import TransactionCase + + +class TestProjectDuplicateSubtask(TransactionCase): + def setUp(self): + super().setUp() + + self.project1 = self.env["project.project"].create({"name": "Project 1"}) + self.task1 = self.env["project.task"].create( + {"name": "name1", "project_id": self.project1.id} + ) + self.subtask1 = self.env["project.task"].create( + {"name": "2", "project_id": self.project1.id, "parent_id": self.task1.id} + ) + self.subtask2 = self.env["project.task"].create( + {"name": "3", "project_id": self.project1.id, "parent_id": self.task1.id} + ) + + def test_check_subtasks(self): + self.task1.action_duplicate_subtasks() + + new_task = self.env["project.task"].search( + [("name", "ilike", self.task1.name), ("name", "ilike", "copy")] + ) + self.assertEqual( + len(new_task.child_ids), 2, "Two subtasks should have been created" + ) + + def test_check_subtasks_of_substasks(self): + self.sub_subtask1_1 = self.env["project.task"].create( + {"name": "4", "project_id": self.project1.id, "parent_id": self.subtask1.id} + ) + self.task1.action_duplicate_subtasks() + + new_task = self.env["project.task"].search( + [("name", "ilike", self.task1.name), ("name", "ilike", "copy")] + ) + self.assertEqual( + len(new_task.child_ids), 2, "Two subtasks should have been created" + ) + new_subtask = self.env["project.task"].search( + [ + ("name", "=", self.subtask1.name + " (copy)"), + ] + ) + self.assertEqual( + len(new_subtask.child_ids), 1, "One subtask should have been created" + ) diff --git a/project_duplicate_subtask/views/project_duplicate_action.xml b/project_duplicate_subtask/views/project_duplicate_action.xml new file mode 100644 index 0000000000..023a7965c9 --- /dev/null +++ b/project_duplicate_subtask/views/project_duplicate_action.xml @@ -0,0 +1,10 @@ + + + + Duplicate with subtasks + + + code + action = records.action_duplicate_subtasks() + +