diff --git a/project_task_project_required/README.rst b/project_task_project_required/README.rst new file mode 100644 index 0000000000..2ae8b16d93 --- /dev/null +++ b/project_task_project_required/README.rst @@ -0,0 +1,86 @@ +================================ +Project: require Project on Task +================================ + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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%2Fproject-lightgray.png?logo=github + :target: https://github.com/OCA/project/tree/12.0/project_task_project_required + :alt: OCA/project +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/project-12-0/project-12-0-project_task_project_required + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/140/12.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to configure task as having project as a mandatory field. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +By installing this module, the project field +will be mandatory for all the companies. + +To make project selection optional on task for a given company: + +# Go to *Project > Configuration > Settings* +# Uncheck *Require Projects on Tasks* + +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 +~~~~~~~ + +* CorporateHub + +Contributors +~~~~~~~~~~~~ + +* `CorporateHub `__ + + * Alexey Pelykh + +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_project_required/__init__.py b/project_task_project_required/__init__.py new file mode 100644 index 0000000000..31660d6a96 --- /dev/null +++ b/project_task_project_required/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import models diff --git a/project_task_project_required/__manifest__.py b/project_task_project_required/__manifest__.py new file mode 100644 index 0000000000..ac60b5e26f --- /dev/null +++ b/project_task_project_required/__manifest__.py @@ -0,0 +1,23 @@ +# Copyright 2019 Brainbean Apps (https://brainbeanapps.com) +# Copyright 2020 CorporateHub (https://corporatehub.eu) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Project: require Project on Task", + "summary": """ + Set project on task as a mandatory field""", + "version": "14.0.1.0.0", + "license": "AGPL-3", + "author": "CorporateHub, " "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/project", + "depends": [ + "project", + ], + "data": [ + "views/project_task.xml", + "views/res_config_settings.xml", + ], + "demo": [ + "demo/res_company.xml", + ], +} diff --git a/project_task_project_required/demo/res_company.xml b/project_task_project_required/demo/res_company.xml new file mode 100644 index 0000000000..8669ee4d95 --- /dev/null +++ b/project_task_project_required/demo/res_company.xml @@ -0,0 +1,16 @@ + + + + + + + + + + diff --git a/project_task_project_required/i18n/it.po b/project_task_project_required/i18n/it.po new file mode 100644 index 0000000000..2bbc336e4e --- /dev/null +++ b/project_task_project_required/i18n/it.po @@ -0,0 +1,62 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * project_task_project_required +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.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_task_project_required +#: model_terms:ir.ui.view,arch_db:project_task_project_required.res_config_settings_view_form +msgid "" +msgstr "" +"" + +#. module: project_task_project_required +#: model:ir.model,name:project_task_project_required.model_res_company +msgid "Companies" +msgstr "Aziende" + +#. module: project_task_project_required +#: model:ir.model,name:project_task_project_required.model_res_config_settings +msgid "Config Settings" +msgstr "Impostazioni di configurazione" + +#. module: project_task_project_required +#: model:ir.model.fields,field_description:project_task_project_required.field_project_task__is_project_required +msgid "Is Project Required" +msgstr "" + +#. module: project_task_project_required +#: model:ir.model.fields,field_description:project_task_project_required.field_res_company__is_project_task_project_required +#: model:ir.model.fields,field_description:project_task_project_required.field_res_config_settings__is_project_task_project_required +msgid "Require Projects on Tasks" +msgstr "" + +#. module: project_task_project_required +#: model_terms:ir.ui.view,arch_db:project_task_project_required.res_config_settings_view_form +msgid "Require project selection on each task by default" +msgstr "" + +#. module: project_task_project_required +#: model:ir.model,name:project_task_project_required.model_project_task +msgid "Task" +msgstr "Lavoro" + +#. module: project_task_project_required +#: code:addons/project_task_project_required/models/project_task.py:20 +#, python-format +msgid "You must specify a project for the task." +msgstr "Deve essere specificato un progetto per il lavoro." diff --git a/project_task_project_required/i18n/project_task_project_required.pot b/project_task_project_required/i18n/project_task_project_required.pot new file mode 100644 index 0000000000..cf5aca23d3 --- /dev/null +++ b/project_task_project_required/i18n/project_task_project_required.pot @@ -0,0 +1,57 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * project_task_project_required +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.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_project_required +#: model_terms:ir.ui.view,arch_db:project_task_project_required.res_config_settings_view_form +msgid "" +msgstr "" + +#. module: project_task_project_required +#: model:ir.model,name:project_task_project_required.model_res_company +msgid "Companies" +msgstr "" + +#. module: project_task_project_required +#: model:ir.model,name:project_task_project_required.model_res_config_settings +msgid "Config Settings" +msgstr "" + +#. module: project_task_project_required +#: model:ir.model.fields,field_description:project_task_project_required.field_project_task__is_project_required +msgid "Is Project Required" +msgstr "" + +#. module: project_task_project_required +#: model:ir.model.fields,field_description:project_task_project_required.field_res_company__is_project_task_project_required +#: model:ir.model.fields,field_description:project_task_project_required.field_res_config_settings__is_project_task_project_required +msgid "Require Projects on Tasks" +msgstr "" + +#. module: project_task_project_required +#: model_terms:ir.ui.view,arch_db:project_task_project_required.res_config_settings_view_form +msgid "Require project selection on each task by default" +msgstr "" + +#. module: project_task_project_required +#: model:ir.model,name:project_task_project_required.model_project_task +msgid "Task" +msgstr "" + +#. module: project_task_project_required +#: code:addons/project_task_project_required/models/project_task.py:20 +#, python-format +msgid "You must specify a project for the task." +msgstr "" + diff --git a/project_task_project_required/i18n/pt_BR.po b/project_task_project_required/i18n/pt_BR.po new file mode 100644 index 0000000000..ccc65a2c8a --- /dev/null +++ b/project_task_project_required/i18n/pt_BR.po @@ -0,0 +1,57 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * project_task_project_required +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.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_task_project_required +#: model_terms:ir.ui.view,arch_db:project_task_project_required.res_config_settings_view_form +msgid "" +msgstr "" + +#. module: project_task_project_required +#: model:ir.model,name:project_task_project_required.model_res_company +msgid "Companies" +msgstr "" + +#. module: project_task_project_required +#: model:ir.model,name:project_task_project_required.model_res_config_settings +msgid "Config Settings" +msgstr "" + +#. module: project_task_project_required +#: model:ir.model.fields,field_description:project_task_project_required.field_project_task__is_project_required +msgid "Is Project Required" +msgstr "" + +#. module: project_task_project_required +#: model:ir.model.fields,field_description:project_task_project_required.field_res_company__is_project_task_project_required +#: model:ir.model.fields,field_description:project_task_project_required.field_res_config_settings__is_project_task_project_required +msgid "Require Projects on Tasks" +msgstr "" + +#. module: project_task_project_required +#: model_terms:ir.ui.view,arch_db:project_task_project_required.res_config_settings_view_form +msgid "Require project selection on each task by default" +msgstr "" + +#. module: project_task_project_required +#: model:ir.model,name:project_task_project_required.model_project_task +msgid "Task" +msgstr "" + +#. module: project_task_project_required +#: code:addons/project_task_project_required/models/project_task.py:20 +#, python-format +msgid "You must specify a project for the task." +msgstr "" diff --git a/project_task_project_required/models/__init__.py b/project_task_project_required/models/__init__.py new file mode 100644 index 0000000000..21d993b212 --- /dev/null +++ b/project_task_project_required/models/__init__.py @@ -0,0 +1,5 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import res_company +from . import project_task +from . import res_config_settings diff --git a/project_task_project_required/models/project_task.py b/project_task_project_required/models/project_task.py new file mode 100644 index 0000000000..c8ad74b27c --- /dev/null +++ b/project_task_project_required/models/project_task.py @@ -0,0 +1,20 @@ +# Copyright 2019 Brainbean Apps (https://brainbeanapps.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import _, api, fields, models +from odoo.exceptions import ValidationError + + +class ProjectTask(models.Model): + _inherit = "project.task" + + is_project_required = fields.Boolean( + string="Is Project Required", + related="company_id.is_project_task_project_required", + ) + + @api.constrains("project_id") + def _check_project_id(self): + for task in self: + if task.is_project_required and not task.project_id: + raise ValidationError(_("You must specify a project for the task.")) diff --git a/project_task_project_required/models/res_company.py b/project_task_project_required/models/res_company.py new file mode 100644 index 0000000000..227d061030 --- /dev/null +++ b/project_task_project_required/models/res_company.py @@ -0,0 +1,13 @@ +# Copyright 2019 Brainbean Apps (https://brainbeanapps.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class ResCompany(models.Model): + _inherit = "res.company" + + is_project_task_project_required = fields.Boolean( + string="Require Projects on Tasks", + default=True, + ) diff --git a/project_task_project_required/models/res_config_settings.py b/project_task_project_required/models/res_config_settings.py new file mode 100644 index 0000000000..5b265fe520 --- /dev/null +++ b/project_task_project_required/models/res_config_settings.py @@ -0,0 +1,14 @@ +# Copyright 2018-2019 Brainbean Apps (https://brainbeanapps.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + _inherit = "res.config.settings" + + is_project_task_project_required = fields.Boolean( + string="Require Projects on Tasks", + related="company_id.is_project_task_project_required", + readonly=False, + ) diff --git a/project_task_project_required/readme/CONFIGURE.rst b/project_task_project_required/readme/CONFIGURE.rst new file mode 100644 index 0000000000..51ed7ea8d2 --- /dev/null +++ b/project_task_project_required/readme/CONFIGURE.rst @@ -0,0 +1,7 @@ +By installing this module, the project field +will be mandatory for all the companies. + +To make project selection optional on task for a given company: + +# Go to *Project > Configuration > Settings* +# Uncheck *Require Projects on Tasks* diff --git a/project_task_project_required/readme/CONTRIBUTORS.rst b/project_task_project_required/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..724bc1d03a --- /dev/null +++ b/project_task_project_required/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `CorporateHub `__ + + * Alexey Pelykh diff --git a/project_task_project_required/readme/DESCRIPTION.rst b/project_task_project_required/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..e358832c9f --- /dev/null +++ b/project_task_project_required/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module allows to configure task as having project as a mandatory field. diff --git a/project_task_project_required/static/description/icon.png b/project_task_project_required/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/project_task_project_required/static/description/icon.png differ diff --git a/project_task_project_required/static/description/index.html b/project_task_project_required/static/description/index.html new file mode 100644 index 0000000000..3ead26b296 --- /dev/null +++ b/project_task_project_required/static/description/index.html @@ -0,0 +1,431 @@ + + + + + + +Project: require Project on Task + + + +
+

Project: require Project on Task

+ + +

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

+

This module allows to configure task as having project as a mandatory field.

+

Table of contents

+ +
+

Configuration

+

By installing this module, the project field +will be mandatory for all the companies.

+

To make project selection optional on task for a given company:

+

# Go to Project > Configuration > Settings +# Uncheck Require Projects on Tasks

+
+
+

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

+
    +
  • 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/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_project_required/tests/__init__.py b/project_task_project_required/tests/__init__.py new file mode 100644 index 0000000000..a945ea0723 --- /dev/null +++ b/project_task_project_required/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import test_project_task_project_required diff --git a/project_task_project_required/tests/test_project_task_project_required.py b/project_task_project_required/tests/test_project_task_project_required.py new file mode 100644 index 0000000000..e49960da41 --- /dev/null +++ b/project_task_project_required/tests/test_project_task_project_required.py @@ -0,0 +1,48 @@ +# Copyright 2019 Brainbean Apps (https://brainbeanapps.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.exceptions import ValidationError +from odoo.tests import TransactionCase + + +class TestProjectTaskProjectRequired(TransactionCase): + def setUp(self): + super().setUp() + + self.Project = self.env["project.project"] + self.ProjectTask = self.env["project.task"] + + self.project = self.Project.create( + { + "name": "Project", + } + ) + + def test_project_required(self): + self.env.user.company_id.is_project_task_project_required = True + with self.assertRaises(ValidationError): + self.ProjectTask.create( + { + "name": "Task A", + } + ) + self.ProjectTask.create( + { + "name": "Task B", + "project_id": self.project.id, + } + ) + + def test_project_not_required(self): + self.env.user.company_id.is_project_task_project_required = False + self.ProjectTask.create( + { + "name": "Task A", + } + ) + self.ProjectTask.create( + { + "name": "Task B", + "project_id": self.project.id, + } + ) diff --git a/project_task_project_required/views/project_task.xml b/project_task_project_required/views/project_task.xml new file mode 100644 index 0000000000..7609844269 --- /dev/null +++ b/project_task_project_required/views/project_task.xml @@ -0,0 +1,55 @@ + + + + + + project.task.tree + project.task + + + + + + + {'required':[('is_project_required','=',True)]} + + + + + + project.task.form + project.task + + + + + + + {'required':[('is_project_required','=',True)]} + + + + + + project.task.form.quick_create + project.task + + + + + + + + + + diff --git a/project_task_project_required/views/res_config_settings.xml b/project_task_project_required/views/res_config_settings.xml new file mode 100644 index 0000000000..5f04f83952 --- /dev/null +++ b/project_task_project_required/views/res_config_settings.xml @@ -0,0 +1,39 @@ + + + + + + res.config.settings.view.form + res.config.settings + + + +
+
+ +
+
+
+
+
+
+
+ +
diff --git a/setup/project_task_project_required/odoo/addons/project_task_project_required b/setup/project_task_project_required/odoo/addons/project_task_project_required new file mode 120000 index 0000000000..b8a2c8e3f1 --- /dev/null +++ b/setup/project_task_project_required/odoo/addons/project_task_project_required @@ -0,0 +1 @@ +../../../../project_task_project_required \ No newline at end of file diff --git a/setup/project_task_project_required/setup.py b/setup/project_task_project_required/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/project_task_project_required/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)