diff --git a/project_template_milestone/README.rst b/project_template_milestone/README.rst new file mode 100644 index 0000000000..56f294ec73 --- /dev/null +++ b/project_template_milestone/README.rst @@ -0,0 +1,104 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +============================ +Project Template & Milestone +============================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:319739b6890f935964898d4a9969b53379dfc01c3d18f2052643460ad075c9e8 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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_template_milestone + :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_template_milestone + :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 adds the function to copy milestones when creating projects +from templates. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use this module, you need to: + +1. If milestones are used on the template, then the milestones will also + be copied when creating a project from the template. + +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 +------- + +* Patrick Wilson +* Open Source Integrators + +Contributors +------------ + +- Patrick Wilson +- Open Source Integrators +- Serpent Consulting Services Pvt. Ltd. +- Le Dinh Tien +- `Komit `__: + + - Vang Nguyen Phu + +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. + +.. |maintainer-patrickrwilson| image:: https://github.com/patrickrwilson.png?size=40px + :target: https://github.com/patrickrwilson + :alt: patrickrwilson + +Current `maintainer `__: + +|maintainer-patrickrwilson| + +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_template_milestone/__init__.py b/project_template_milestone/__init__.py new file mode 100644 index 0000000000..69f7babdfb --- /dev/null +++ b/project_template_milestone/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import models diff --git a/project_template_milestone/__manifest__.py b/project_template_milestone/__manifest__.py new file mode 100644 index 0000000000..585941edf7 --- /dev/null +++ b/project_template_milestone/__manifest__.py @@ -0,0 +1,18 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Project Template & Milestone", + "summary": """Adds function to copy of milestones when creating + a project from template""", + "author": "Patrick Wilson, Odoo Community Association (OCA)," + "Open Source Integrators", + "website": "https://github.com/OCA/project", + "category": "Project Management", + "version": "19.0.1.0.0", + "license": "AGPL-3", + "depends": ["project_template"], + "application": False, + "auto_install": True, + "development_status": "Beta", + "maintainers": ["patrickrwilson"], +} diff --git a/project_template_milestone/i18n/de.po b/project_template_milestone/i18n/de.po new file mode 100644 index 0000000000..af8b428743 --- /dev/null +++ b/project_template_milestone/i18n/de.po @@ -0,0 +1,22 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * project_template_milestone +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2019-07-09 13: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: project_template_milestone +#: model:ir.model,name:project_template_milestone.model_project_project +msgid "Project" +msgstr "Projekt" diff --git a/project_template_milestone/i18n/it.po b/project_template_milestone/i18n/it.po new file mode 100644 index 0000000000..9d7635034a --- /dev/null +++ b/project_template_milestone/i18n/it.po @@ -0,0 +1,25 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * project_template_milestone +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2020-05-31 10:09+0000\n" +"Last-Translator: Sergio Zanchetta \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 3.10\n" + +#. module: project_template_milestone +#: model:ir.model,name:project_template_milestone.model_project_project +msgid "Project" +msgstr "" + +#~ msgid "WBS element" +#~ msgstr "Elemento WBS" diff --git a/project_template_milestone/i18n/project_template_milestone.pot b/project_template_milestone/i18n/project_template_milestone.pot new file mode 100644 index 0000000000..5869a7e135 --- /dev/null +++ b/project_template_milestone/i18n/project_template_milestone.pot @@ -0,0 +1,19 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * project_template_milestone +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.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_template_milestone +#: model:ir.model,name:project_template_milestone.model_project_project +msgid "Project" +msgstr "" diff --git a/project_template_milestone/i18n/pt.po b/project_template_milestone/i18n/pt.po new file mode 100644 index 0000000000..254a8b3df1 --- /dev/null +++ b/project_template_milestone/i18n/pt.po @@ -0,0 +1,25 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * project_template_milestone +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2020-01-10 13:13+0000\n" +"Last-Translator: Pedro Castro Silva \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 3.10\n" + +#. module: project_template_milestone +#: model:ir.model,name:project_template_milestone.model_project_project +msgid "Project" +msgstr "" + +#~ msgid "WBS element" +#~ msgstr "Elemento WBS" diff --git a/project_template_milestone/i18n/pt_BR.po b/project_template_milestone/i18n/pt_BR.po new file mode 100644 index 0000000000..d9c44328fa --- /dev/null +++ b/project_template_milestone/i18n/pt_BR.po @@ -0,0 +1,20 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * project_template_milestone +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\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" + +#. module: project_template_milestone +#: model:ir.model,name:project_template_milestone.model_project_project +msgid "Project" +msgstr "" diff --git a/project_template_milestone/i18n/sl.po b/project_template_milestone/i18n/sl.po new file mode 100644 index 0000000000..5920342828 --- /dev/null +++ b/project_template_milestone/i18n/sl.po @@ -0,0 +1,26 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * project_template_milestone +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2020-03-31 10:14+0000\n" +"Last-Translator: Matjaz Mozetic \n" +"Language-Team: none\n" +"Language: sl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=4; plural=n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n" +"%100==4 ? 2 : 3;\n" +"X-Generator: Weblate 3.10\n" + +#. module: project_template_milestone +#: model:ir.model,name:project_template_milestone.model_project_project +msgid "Project" +msgstr "" + +#~ msgid "WBS element" +#~ msgstr "Projektni člen" diff --git a/project_template_milestone/models/__init__.py b/project_template_milestone/models/__init__.py new file mode 100644 index 0000000000..bd39495a09 --- /dev/null +++ b/project_template_milestone/models/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import project diff --git a/project_template_milestone/models/project.py b/project_template_milestone/models/project.py new file mode 100644 index 0000000000..260cf31d7e --- /dev/null +++ b/project_template_milestone/models/project.py @@ -0,0 +1,23 @@ +# Copyright 2019 Patrick Wilson +# Copyright (C) 2021 Open Source Integrators +# Copyright (C) 2021 Serpent Consulting Services +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import models + + +class ProjectTemplate(models.Model): + _inherit = "project.project" + + def create_project_from_template(self): + self.ensure_one() + res = super().create_project_from_template() + project = self.browse(res["res_id"]) + for milestone in self.milestone_ids: + milestone.copy(default={"project_id": project.id}) + # LINK THE NEWLY CREATED TASKS TO THE NEWLY CREATED MILESTONES + for new_task_record in project.task_ids: + for new_milestone_record in project.milestone_ids: + if new_task_record.milestone_id.name == new_milestone_record.name: + new_task_record.milestone_id = new_milestone_record.id + return res diff --git a/project_template_milestone/pyproject.toml b/project_template_milestone/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/project_template_milestone/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/project_template_milestone/readme/CONTRIBUTORS.md b/project_template_milestone/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..6a3cb8e011 --- /dev/null +++ b/project_template_milestone/readme/CONTRIBUTORS.md @@ -0,0 +1,6 @@ +- Patrick Wilson \ +- Open Source Integrators +- Serpent Consulting Services Pvt. Ltd. \ +- Le Dinh Tien \\> +- [Komit](https://komit-consulting.com): + - Vang Nguyen Phu \ No newline at end of file diff --git a/project_template_milestone/readme/DESCRIPTION.md b/project_template_milestone/readme/DESCRIPTION.md new file mode 100644 index 0000000000..7f61556da5 --- /dev/null +++ b/project_template_milestone/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module adds the function to copy milestones when creating projects +from templates. diff --git a/project_template_milestone/readme/USAGE.md b/project_template_milestone/readme/USAGE.md new file mode 100644 index 0000000000..ea09e53004 --- /dev/null +++ b/project_template_milestone/readme/USAGE.md @@ -0,0 +1,4 @@ +To use this module, you need to: + +1. If milestones are used on the template, then the milestones will + also be copied when creating a project from the template. diff --git a/project_template_milestone/static/description/icon.png b/project_template_milestone/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/project_template_milestone/static/description/icon.png differ diff --git a/project_template_milestone/static/description/index.html b/project_template_milestone/static/description/index.html new file mode 100644 index 0000000000..d3fb498426 --- /dev/null +++ b/project_template_milestone/static/description/index.html @@ -0,0 +1,449 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Project Template & Milestone

+ +

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

+

This module adds the function to copy milestones when creating projects +from templates.

+

Table of contents

+ +
+

Usage

+

To use this module, you need to:

+
    +
  1. If milestones are used on the template, then the milestones will also +be copied when creating a project from the template.
  2. +
+
+
+

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

+
    +
  • Patrick Wilson
  • +
  • Open Source Integrators
  • +
+
+
+

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.

+

Current maintainer:

+

patrickrwilson

+

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_template_milestone/tests/__init__.py b/project_template_milestone/tests/__init__.py new file mode 100644 index 0000000000..33d24e659b --- /dev/null +++ b/project_template_milestone/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import test_project_template diff --git a/project_template_milestone/tests/test_project_template.py b/project_template_milestone/tests/test_project_template.py new file mode 100644 index 0000000000..9919e89b84 --- /dev/null +++ b/project_template_milestone/tests/test_project_template.py @@ -0,0 +1,88 @@ +# Copyright 2019 Patrick Wilson +# Copyright (C) 2021 Open Source Integrators +# Copyright (C) 2021 Serpent Consulting Services +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.tests import common + + +class TestProjectTemplate(common.TransactionCase): + def setUp(self): + super().setUp() + self.test_customer = self.env["res.partner"].create({"name": "TestCustomer"}) + + # Create project with 2 milestones + self.test_project = self.env["project.project"].create( + { + "name": "TestProject", + "alias_name": "test_alias", + "partner_id": self.test_customer.id, + } + ) + self.test_milestone_1 = self.env["project.milestone"].create( + {"name": "Test_Milestone_1", "project_id": self.test_project.id} + ) + self.test_milestone_2 = self.env["project.milestone"].create( + {"name": "Test_Milestone_2", "project_id": self.test_project.id} + ) + + # Create 2 tasks for milestone 1 + self.env["project.task"].create( + { + "name": "TestTask_1", + "project_id": self.test_project.id, + "milestone_id": self.test_milestone_1.id, + } + ) + self.env["project.task"].create( + { + "name": "TestTask_2", + "project_id": self.test_project.id, + "milestone_id": self.test_milestone_1.id, + } + ) + + # Create 1 tasks for milestone 2 + self.env["project.task"].create( + { + "name": "TestTask_3", + "project_id": self.test_project.id, + "milestone_id": self.test_milestone_2.id, + } + ) + + # TEST 01: Create project from template and verify milestones & tasks + def test_create_project_from_template(self): + # Set Project Template + project_01 = self.test_project + project_01.is_template = True + project_01.on_change_is_template() + + # Create new Project from Template + project_01.create_project_from_template() + new_project = self.env["project.project"].search( + [("name", "=", "TestProject (COPY)")] + ) + + # Verify that the project was created successfully + self.assertEqual(len(new_project), 1) + + # Verify that the Milestones were created successfully + self.assertEqual(len(new_project.milestone_ids), 2) + + # Verify that the tasks were created successfully with milestones + task_milestone_1_ids = self.env["project.task"].search( + [ + ("milestone_id.name", "=", "Test_Milestone_1"), + ("project_id", "=", new_project.id), + ] + ) + self.assertEqual(len(task_milestone_1_ids), 2) + + task_milestone_2_ids = self.env["project.task"].search( + [ + ("milestone_id.name", "=", "Test_Milestone_2"), + ("project_id", "=", new_project.id), + ] + ) + self.assertEqual(len(task_milestone_2_ids), 1)