diff --git a/base_automation_team_activity/README.rst b/base_automation_team_activity/README.rst new file mode 100644 index 0000000000..083bc88dfe --- /dev/null +++ b/base_automation_team_activity/README.rst @@ -0,0 +1,98 @@ +============================= +Base Automation Team Activity +============================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:9edd6734fb63585bb30d837a2790deab0eb651be53cd6e7dee21f1d096f9826a + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png + :target: https://odoo-community.org/page/development-status + :alt: Alpha +.. |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%2Fserver--ux-lightgray.png?logo=github + :target: https://github.com/OCA/server-ux/tree/14.0/base_automation_team_activity + :alt: OCA/server-ux +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/server-ux-14-0/server-ux-14-0-base_automation_team_activity + :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/server-ux&target_branch=14.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This add-on allows the creation of team activities using Odoo's automated action. + +.. IMPORTANT:: + This is an alpha version, the data model and design can change at any time without warning. + Only for development or testing purpose, do not use in production. + `More details on development status `_ + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use this add-on, you just need to change the "Activity User Type" +field to "team" and select the group you want to use. + +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 +~~~~~~~ + +* Binhex + +Contributors +~~~~~~~~~~~~ + +* `Binhex _`: + + * Adasat Torres de León + + +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-adasatorres| image:: https://github.com/adasatorres.png?size=40px + :target: https://github.com/adasatorres + :alt: adasatorres + +Current `maintainer `__: + +|maintainer-adasatorres| + +This module is part of the `OCA/server-ux `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/base_automation_team_activity/__init__.py b/base_automation_team_activity/__init__.py new file mode 100644 index 0000000000..e6c5c762e2 --- /dev/null +++ b/base_automation_team_activity/__init__.py @@ -0,0 +1,3 @@ +# Copyright 2024 Binhex - Adasat Torres +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from . import models diff --git a/base_automation_team_activity/__manifest__.py b/base_automation_team_activity/__manifest__.py new file mode 100644 index 0000000000..ecd591121d --- /dev/null +++ b/base_automation_team_activity/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright 2024 Binhex - Adasat Torres +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + "name": "Base Automation Team Activity", + "summary": "Add team activity support to base_automation", + "category": "Tools", + "development_status": "Alpha", + "version": "14.0.1.0.0", + "depends": ["base_automation", "mail_activity_team"], + "data": [ + "views/ir_actions_server_views.xml", + ], + "author": "Binhex, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/server-ux", + "license": "AGPL-3", + "installable": True, + "maintainers": ["adasatorres"], +} diff --git a/base_automation_team_activity/i18n/base_automation_team_activity.pot b/base_automation_team_activity/i18n/base_automation_team_activity.pot new file mode 100644 index 0000000000..2123c83aee --- /dev/null +++ b/base_automation_team_activity/i18n/base_automation_team_activity.pot @@ -0,0 +1,69 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_automation_team_activity +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0-20231106\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-10-21 11:59+0000\n" +"PO-Revision-Date: 2024-10-21 11:59+0000\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: base_automation_team_activity +#: model:ir.model.fields,field_description:base_automation_team_activity.field_base_automation__activity_user_type +#: model:ir.model.fields,field_description:base_automation_team_activity.field_ir_actions_server__activity_user_type +#: model:ir.model.fields,field_description:base_automation_team_activity.field_ir_cron__activity_user_type +msgid "Activity User Type" +msgstr "" + +#. module: base_automation_team_activity +#: model:ir.model.fields,field_description:base_automation_team_activity.field_ir_actions_server__display_name +msgid "Display Name" +msgstr "" + +#. module: base_automation_team_activity +#: model:ir.model.fields,field_description:base_automation_team_activity.field_ir_actions_server__id +msgid "ID" +msgstr "" + +#. module: base_automation_team_activity +#: model:ir.model.fields,field_description:base_automation_team_activity.field_ir_actions_server____last_update +msgid "Last Modified on" +msgstr "" + +#. module: base_automation_team_activity +#: model:ir.model,name:base_automation_team_activity.model_ir_actions_server +msgid "Server Action" +msgstr "" + +#. module: base_automation_team_activity +#: code:addons/base_automation_team_activity/models/ir_actions_server.py:0 +#: model:ir.model.fields.selection,name:base_automation_team_activity.selection__ir_actions_server__activity_user_type__team +#, python-format +msgid "Specific Team" +msgstr "" + +#. module: base_automation_team_activity +#: model:ir.model.fields,field_description:base_automation_team_activity.field_base_automation__team_id +#: model:ir.model.fields,field_description:base_automation_team_activity.field_ir_actions_server__team_id +#: model:ir.model.fields,field_description:base_automation_team_activity.field_ir_cron__team_id +msgid "Team" +msgstr "" + +#. module: base_automation_team_activity +#: model:ir.model.fields,help:base_automation_team_activity.field_base_automation__activity_user_type +#: model:ir.model.fields,help:base_automation_team_activity.field_ir_actions_server__activity_user_type +#: model:ir.model.fields,help:base_automation_team_activity.field_ir_cron__activity_user_type +msgid "" +"Use 'Specific User' to always assign the same user on the next activity.\n" +" Use 'Generic User From Record' to specify the field name of the user\n" +" to choose on the record.\n" +" Use 'Specific Team' to always assign the same team on the next activity.\n" +" " +msgstr "" diff --git a/base_automation_team_activity/i18n/es.po b/base_automation_team_activity/i18n/es.po new file mode 100644 index 0000000000..4b7b972c08 --- /dev/null +++ b/base_automation_team_activity/i18n/es.po @@ -0,0 +1,82 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_automation_team_activity +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0-20231106\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-10-21 11:59+0000\n" +"PO-Revision-Date: 2024-10-21 13:00+0100\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Poedit 3.5\n" + +#. module: base_automation_team_activity +#: model:ir.model.fields,field_description:base_automation_team_activity.field_base_automation__activity_user_type +#: model:ir.model.fields,field_description:base_automation_team_activity.field_ir_actions_server__activity_user_type +#: model:ir.model.fields,field_description:base_automation_team_activity.field_ir_cron__activity_user_type +msgid "Activity User Type" +msgstr "Tipo de actividad de usuario" + +#. module: base_automation_team_activity +#: model:ir.model.fields,field_description:base_automation_team_activity.field_ir_actions_server__display_name +msgid "Display Name" +msgstr "Nombre a mostrar" + +#. module: base_automation_team_activity +#: model:ir.model.fields,field_description:base_automation_team_activity.field_ir_actions_server__id +msgid "ID" +msgstr "ID" + +#. module: base_automation_team_activity +#: model:ir.model.fields,field_description:base_automation_team_activity.field_ir_actions_server____last_update +msgid "Last Modified on" +msgstr "Ultima modificación el" + +#. module: base_automation_team_activity +#: model:ir.model,name:base_automation_team_activity.model_ir_actions_server +msgid "Server Action" +msgstr "Acción del servidor" + +#. module: base_automation_team_activity +#: code:addons/base_automation_team_activity/models/ir_actions_server.py:0 +#: model:ir.model.fields.selection,name:base_automation_team_activity.selection__ir_actions_server__activity_user_type__team +#, python-format +msgid "Specific Team" +msgstr "Equipo específico" + +#. module: base_automation_team_activity +#: model:ir.model.fields,field_description:base_automation_team_activity.field_base_automation__team_id +#: model:ir.model.fields,field_description:base_automation_team_activity.field_ir_actions_server__team_id +#: model:ir.model.fields,field_description:base_automation_team_activity.field_ir_cron__team_id +msgid "Team" +msgstr "Equipo" + +#. module: base_automation_team_activity +#: model:ir.model.fields,help:base_automation_team_activity.field_base_automation__activity_user_type +#: model:ir.model.fields,help:base_automation_team_activity.field_ir_actions_server__activity_user_type +#: model:ir.model.fields,help:base_automation_team_activity.field_ir_cron__activity_user_type +msgid "" +"Use 'Specific User' to always assign the same user on the next " +"activity.\n" +" Use 'Generic User From Record' to specify the field name of the " +"user\n" +" to choose on the record.\n" +" Use 'Specific Team' to always assign the same team on the next " +"activity.\n" +" " +msgstr "" +"Utilice 'Usuario Específico' para asignar siempre el mismo usuario en " +"la siguiente actividad.\n" +" Utilice 'Usuario genérico del registro' para especificar el " +"nombre del campo del usuario\n" +" a elegir en el registro.\n" +" Utilice \"Equipo específico\" para asignar siempre el mismo " +"equipo a la siguiente actividad.\n" +" " diff --git a/base_automation_team_activity/models/__init__.py b/base_automation_team_activity/models/__init__.py new file mode 100644 index 0000000000..272fe60c16 --- /dev/null +++ b/base_automation_team_activity/models/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2024 Binhex - Adasat Torres +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from . import ir_actions_server +from . import mail_activity_mixin diff --git a/base_automation_team_activity/models/ir_actions_server.py b/base_automation_team_activity/models/ir_actions_server.py new file mode 100644 index 0000000000..cad885cfce --- /dev/null +++ b/base_automation_team_activity/models/ir_actions_server.py @@ -0,0 +1,29 @@ +# Copyright 2024 Binhex - Adasat Torres +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + + +class IrActionsServer(models.Model): + _inherit = "ir.actions.server" + + activity_user_type = fields.Selection( + selection_add=[ + ("team", "Specific Team"), + ], + ondelete={"team": "cascade"}, + help="""Use 'Specific User' to always assign the same user on the next activity. + Use 'Generic User From Record' to specify the field name of the user + to choose on the record. + Use 'Specific Team' to always assign the same team on the next activity. + """, + ) + team_id = fields.Many2one( + comodel_name="mail.activity.team", string="Team", ondelete="cascade" + ) + + def _run_action_next_activity(self, eval_context=None): + if self.activity_user_type == "team": + self = self.with_context(mail_activity_team_id=self.team_id.id) + super()._run_action_next_activity(eval_context) + return False diff --git a/base_automation_team_activity/models/mail_activity_mixin.py b/base_automation_team_activity/models/mail_activity_mixin.py new file mode 100644 index 0000000000..f618d50a20 --- /dev/null +++ b/base_automation_team_activity/models/mail_activity_mixin.py @@ -0,0 +1,15 @@ +from odoo import models + + +class MailActivityMixin(models.AbstractModel): + _inherit = "mail.activity.mixin" + + def activity_schedule( + self, act_type_xmlid="", date_deadline=None, summary="", note="", **act_values + ): + team_id = self.env.context.get("mail_activity_team_id") + if team_id: + act_values.update({"team_id": team_id, "user_id": False}) + super().activity_schedule( + act_type_xmlid, date_deadline, summary, note, **act_values + ) diff --git a/base_automation_team_activity/readme/CONTRIBUTORS.rst b/base_automation_team_activity/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..2be2cb25ab --- /dev/null +++ b/base_automation_team_activity/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* `Binhex _`: + + * Adasat Torres de León + diff --git a/base_automation_team_activity/readme/DESCRIPTION.rst b/base_automation_team_activity/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..5175b63751 --- /dev/null +++ b/base_automation_team_activity/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This add-on allows the creation of team activities using Odoo's automated action. diff --git a/base_automation_team_activity/readme/USAGE.rst b/base_automation_team_activity/readme/USAGE.rst new file mode 100644 index 0000000000..2d055c106e --- /dev/null +++ b/base_automation_team_activity/readme/USAGE.rst @@ -0,0 +1,2 @@ +To use this add-on, you just need to change the "Activity User Type" +field to "team" and select the group you want to use. diff --git a/base_automation_team_activity/static/description/icon.png b/base_automation_team_activity/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/base_automation_team_activity/static/description/icon.png differ diff --git a/base_automation_team_activity/static/description/index.html b/base_automation_team_activity/static/description/index.html new file mode 100644 index 0000000000..2a35d10e95 --- /dev/null +++ b/base_automation_team_activity/static/description/index.html @@ -0,0 +1,440 @@ + + + + + +Base Automation Team Activity + + + +
+

Base Automation Team Activity

+ + +

Alpha License: AGPL-3 OCA/server-ux Translate me on Weblate Try me on Runboat

+

This add-on allows the creation of team activities using Odoo’s automated action.

+
+

Important

+

This is an alpha version, the data model and design can change at any time without warning. +Only for development or testing purpose, do not use in production. +More details on development status

+
+

Table of contents

+ +
+

Usage

+

To use this add-on, you just need to change the “Activity User Type” +field to “team” and select the group you want to use.

+
+
+

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

+
    +
  • Binhex
  • +
+
+
+

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:

+

adasatorres

+

This module is part of the OCA/server-ux project on GitHub.

+

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

+
+
+
+ + diff --git a/base_automation_team_activity/tests/__init__.py b/base_automation_team_activity/tests/__init__.py new file mode 100644 index 0000000000..e7586e891b --- /dev/null +++ b/base_automation_team_activity/tests/__init__.py @@ -0,0 +1,3 @@ +# Copyright 2024 Binhex - Adasat Torres +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from . import test_team_activity diff --git a/base_automation_team_activity/tests/test_team_activity.py b/base_automation_team_activity/tests/test_team_activity.py new file mode 100644 index 0000000000..26d0715310 --- /dev/null +++ b/base_automation_team_activity/tests/test_team_activity.py @@ -0,0 +1,108 @@ +# Copyright 2024 Binhex - Adasat Torres +# 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("-at_install", "post_install") +class TestTeamActivity(TransactionCase): + def setUp(self): + super().setUp() + self.admin_user = self.env.ref("base.user_root") + self.team_id = self.env["mail.activity.team"].create( + { + "name": "Test Team", + "user_id": self.admin_user.id, + } + ) + self.contact_id = self.env["res.partner"].create( + {"name": "Test Contact", "email": "test@test.com"} + ) + + self.test_automation_id = self.env["base.automation"].create( + { + "name": "Test", + "active": True, + "model_id": self.env.ref("base.model_res_partner").id, + "trigger": "on_write", + "trigger_field_ids": [ + ( + 4, + self.env.ref("base.field_res_partner__email").id, + ) + ], + "state": "next_activity", + "activity_type_id": self.env.ref("mail.mail_activity_data_todo").id, + "activity_summary": "Test Summary", + "activity_note": "Test Note", + "activity_date_deadline_range": 1, + "activity_date_deadline_range_type": "days", + "activity_user_type": "team", + "team_id": self.team_id.id, + } + ) + self.test2_automation_id = self.env["base.automation"].create( + { + "name": "Test2", + "active": True, + "model_id": self.env.ref("base.model_res_partner").id, + "trigger": "on_write", + "trigger_field_ids": [ + ( + 4, + self.env.ref("base.field_res_partner__name").id, + ) + ], + "state": "next_activity", + "activity_type_id": False, + "activity_summary": "Test Summary", + "activity_note": "Test Note", + "activity_date_deadline_range": 1, + "activity_date_deadline_range_type": "days", + "activity_user_type": "team", + "team_id": self.team_id.id, + } + ) + self.test3_automation_id = self.env["base.automation"].create( + { + "name": "Test3", + "active": True, + "model_id": self.env.ref("base.model_res_partner").id, + "trigger": "on_write", + "trigger_field_ids": [ + ( + 4, + self.env.ref("base.field_res_partner__name").id, + ) + ], + "state": "next_activity", + "activity_type_id": self.env.ref("mail.mail_activity_data_todo").id, + "activity_summary": "Test Summary", + "activity_note": "Test Note", + "activity_date_deadline_range": 1, + "activity_date_deadline_range_type": "days", + "activity_user_type": "specific", + "activity_user_id": self.admin_user.id, + } + ) + + def test_change_partner_email(self): + self.assertEqual(len(self.contact_id.activity_ids), 0) + self.contact_id.email = "test@test2.com" + self.assertEqual(len(self.contact_id.activity_ids), 1) + activities = self.contact_id.activity_ids.filtered( + lambda activity: activity.team_id.id == self.team_id.id + ) + self.assertEqual(len(activities), 1) + + def test_fail_change_partner_name(self): + self.test3_automation_id.active = False + self.assertEqual(len(self.contact_id.activity_ids), 0) + self.contact_id.name = "Test Contact 2" + self.assertEqual(len(self.contact_id.activity_ids), 0) + + def test_normal_activity(self): + self.test2_automation_id.active = False + self.assertEqual(len(self.contact_id.activity_ids), 0) + self.contact_id.name = "Test Contact 3" + self.assertFalse(self.env.context.get("mail_activity_team_id")) diff --git a/base_automation_team_activity/views/ir_actions_server_views.xml b/base_automation_team_activity/views/ir_actions_server_views.xml new file mode 100644 index 0000000000..115f18bdfa --- /dev/null +++ b/base_automation_team_activity/views/ir_actions_server_views.xml @@ -0,0 +1,40 @@ + + + + + ir.actions.server.form.inherit + ir.actions.server + + + + + { + 'invisible': [('activity_user_type', '!=', 'generic')], + 'required': [('state', '=', 'next_activity'), ('activity_user_type', '=', 'generic')] + } + + + + + { + 'invisible': [('activity_user_type', '!=', 'specific')], + 'required': [('state', '=', 'next_activity'), ('activity_user_type', '=', 'specific')] + } + + + + + + + + + diff --git a/setup/base_automation_team_activity/odoo/addons/base_automation_team_activity b/setup/base_automation_team_activity/odoo/addons/base_automation_team_activity new file mode 120000 index 0000000000..e04c3529f0 --- /dev/null +++ b/setup/base_automation_team_activity/odoo/addons/base_automation_team_activity @@ -0,0 +1 @@ +../../../../base_automation_team_activity \ No newline at end of file diff --git a/setup/base_automation_team_activity/setup.py b/setup/base_automation_team_activity/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/base_automation_team_activity/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)