diff --git a/mail_activity_multiple_users/README.rst b/mail_activity_multiple_users/README.rst new file mode 100644 index 0000000000..4fdd12b941 --- /dev/null +++ b/mail_activity_multiple_users/README.rst @@ -0,0 +1,83 @@ +============================ +Mail Activity Multiple Users +============================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:19cd5d81e4016b286acd3e8ca8183f39ea255d15f758291399341c5a81744226 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fsocial-lightgray.png?logo=github + :target: https://github.com/OCA/social/tree/16.0/mail_activity_multiple_users + :alt: OCA/social +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/social-16-0/social-16-0-mail_activity_multiple_users + :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/social&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This addon allows to create several activities for several users at once, if needded. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To create activities for several users at once check 'Multiple users activity?' on the activities form, during creation. From there, select the users to which the activities will be assigned. + +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 `_: + + * Ariel Barreiros + +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/social `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/mail_activity_multiple_users/__init__.py b/mail_activity_multiple_users/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/mail_activity_multiple_users/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/mail_activity_multiple_users/__manifest__.py b/mail_activity_multiple_users/__manifest__.py new file mode 100644 index 0000000000..3c3d81a40d --- /dev/null +++ b/mail_activity_multiple_users/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2024 Binhex () +# Copyright 2024 Binhex Ariel Barreiros +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) +{ + "name": "Mail Activity Multiple Users", + "summary": """This module allows to create several + activities for several users at once, if needded""", + "version": "16.0.1.0.0", + "category": "Social Network", + "author": "Binhex, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/social", + "license": "AGPL-3", + "depends": ["mail"], + "data": ["views/mail_activity_view.xml"], + "installable": True, +} diff --git a/mail_activity_multiple_users/i18n/es.po b/mail_activity_multiple_users/i18n/es.po new file mode 100644 index 0000000000..2a1cca6cf0 --- /dev/null +++ b/mail_activity_multiple_users/i18n/es.po @@ -0,0 +1,58 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_activity_multiple_users +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-07-05 08:13+0000\n" +"PO-Revision-Date: 2024-07-05 08:13+0000\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: \n" +"Plural-Forms: \n" + +#. module: mail_activity_multiple_users +#: code:addons/mail_activity_multiple_users/models/mail_activity.py:0 +#: model:ir.model.fields,help:mail_activity_multiple_users.field_mail_activity__user_ids +#, python-format +msgid "Activities will be created for this list of users" +msgstr "Se crearán actividades para esta lista de usuarios" + +#. module: mail_activity_multiple_users +#: model:ir.model,name:mail_activity_multiple_users.model_mail_activity +msgid "Activity" +msgstr "Actividad" + +#. module: mail_activity_multiple_users +#: code:addons/mail_activity_multiple_users/models/mail_activity.py:0 +#: model:ir.model.fields,field_description:mail_activity_multiple_users.field_mail_activity__user_ids +#, python-format +msgid "Assigned Users" +msgstr "Usuarios asignados" + +#. module: mail_activity_multiple_users +#: model:ir.model.fields,field_description:mail_activity_multiple_users.field_mail_activity__display_name +msgid "Display Name" +msgstr "Nombre mostrado" + +#. module: mail_activity_multiple_users +#: model:ir.model.fields,field_description:mail_activity_multiple_users.field_mail_activity__id +msgid "ID" +msgstr "ID" + +#. module: mail_activity_multiple_users +#: model:ir.model.fields,field_description:mail_activity_multiple_users.field_mail_activity____last_update +msgid "Last Modified on" +msgstr "Última modificación el" + +#. module: mail_activity_multiple_users +#: code:addons/mail_activity_multiple_users/models/mail_activity.py:0 +#: model:ir.model.fields,field_description:mail_activity_multiple_users.field_mail_activity__is_multiple_users_activity +#, python-format +msgid "Multiple users activity?" +msgstr "¿Actividad de varios usuarios?" diff --git a/mail_activity_multiple_users/i18n/mail_activity_multiple_users.pot b/mail_activity_multiple_users/i18n/mail_activity_multiple_users.pot new file mode 100644 index 0000000000..e5d0fc1780 --- /dev/null +++ b/mail_activity_multiple_users/i18n/mail_activity_multiple_users.pot @@ -0,0 +1,57 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_activity_multiple_users +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-07-05 08:13+0000\n" +"PO-Revision-Date: 2024-07-05 08:13+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: mail_activity_multiple_users +#: code:addons/mail_activity_multiple_users/models/mail_activity.py:0 +#: model:ir.model.fields,help:mail_activity_multiple_users.field_mail_activity__user_ids +#, python-format +msgid "Activities will be created for this list of users" +msgstr "" + +#. module: mail_activity_multiple_users +#: model:ir.model,name:mail_activity_multiple_users.model_mail_activity +msgid "Activity" +msgstr "" + +#. module: mail_activity_multiple_users +#: code:addons/mail_activity_multiple_users/models/mail_activity.py:0 +#: model:ir.model.fields,field_description:mail_activity_multiple_users.field_mail_activity__user_ids +#, python-format +msgid "Assigned Users" +msgstr "" + +#. module: mail_activity_multiple_users +#: model:ir.model.fields,field_description:mail_activity_multiple_users.field_mail_activity__display_name +msgid "Display Name" +msgstr "" + +#. module: mail_activity_multiple_users +#: model:ir.model.fields,field_description:mail_activity_multiple_users.field_mail_activity__id +msgid "ID" +msgstr "" + +#. module: mail_activity_multiple_users +#: model:ir.model.fields,field_description:mail_activity_multiple_users.field_mail_activity____last_update +msgid "Last Modified on" +msgstr "" + +#. module: mail_activity_multiple_users +#: code:addons/mail_activity_multiple_users/models/mail_activity.py:0 +#: model:ir.model.fields,field_description:mail_activity_multiple_users.field_mail_activity__is_multiple_users_activity +#, python-format +msgid "Multiple users activity?" +msgstr "" diff --git a/mail_activity_multiple_users/models/__init__.py b/mail_activity_multiple_users/models/__init__.py new file mode 100644 index 0000000000..1ff3880296 --- /dev/null +++ b/mail_activity_multiple_users/models/__init__.py @@ -0,0 +1 @@ +from . import mail_activity diff --git a/mail_activity_multiple_users/models/mail_activity.py b/mail_activity_multiple_users/models/mail_activity.py new file mode 100644 index 0000000000..0e8dd25cda --- /dev/null +++ b/mail_activity_multiple_users/models/mail_activity.py @@ -0,0 +1,49 @@ +# Copyright 2024 Binhex () +# Copyright 2024 Binhex Ariel Barreiros +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +from odoo import api, fields, models + + +class MailActivity(models.Model): + _inherit = "mail.activity" + + def _default_is_module_calendar_installed(self): + module = self.env["ir.module.module"].sudo().search([("name", "=", "calendar")]) + return True if module and module.state == "installed" else False + + user_ids = fields.Many2many( + "res.users", + string="Assigned Users", + help="Activities will be created for this list of users", + ) + is_multiple_users_activity = fields.Boolean(string="Multiple users activity?") + is_module_calendar_installed = fields.Boolean( + readonly=True, default=_default_is_module_calendar_installed + ) + + @api.model_create_multi + def _create(self, values): + res = super(MailActivity, self)._create(values) + if res.user_id in res.user_ids: + res.user_ids = [(3, res.user_id.id)] + if res.is_multiple_users_activity: + res.is_multiple_users_activity = False + for user in res.user_ids: + self.create( + { + "res_model_id": res.res_model_id.id, + "res_id": res.res_id, + "activity_type_id": res.activity_type_id.id, + "date_deadline": res.date_deadline, + "user_id": user.id, + "summary": res.summary, + "note": res.note, + } + ) + return res + + @api.onchange("user_ids") + def _onchange_user_ids(self): + if self.user_ids: + self.user_id = self.user_ids[0] diff --git a/mail_activity_multiple_users/readme/CONTRIBUTORS.rst b/mail_activity_multiple_users/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..c53028c358 --- /dev/null +++ b/mail_activity_multiple_users/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Binhex `_: + + * Ariel Barreiros diff --git a/mail_activity_multiple_users/readme/DESCRIPTION.rst b/mail_activity_multiple_users/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..fd3369b459 --- /dev/null +++ b/mail_activity_multiple_users/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This addon allows to create several activities for several users at once, if needded. diff --git a/mail_activity_multiple_users/readme/USAGE.rst b/mail_activity_multiple_users/readme/USAGE.rst new file mode 100644 index 0000000000..1613b1f89c --- /dev/null +++ b/mail_activity_multiple_users/readme/USAGE.rst @@ -0,0 +1 @@ +To create activities for several users at once check 'Multiple users activity?' on the activities form, during creation. From there, select the users to which the activities will be assigned. diff --git a/mail_activity_multiple_users/static/description/icon.png b/mail_activity_multiple_users/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/mail_activity_multiple_users/static/description/icon.png differ diff --git a/mail_activity_multiple_users/static/description/index.html b/mail_activity_multiple_users/static/description/index.html new file mode 100644 index 0000000000..864f78288b --- /dev/null +++ b/mail_activity_multiple_users/static/description/index.html @@ -0,0 +1,431 @@ + + + + + +Mail Activity Multiple Users + + + +
+

Mail Activity Multiple Users

+ + +

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

+

This addon allows to create several activities for several users at once, if needded.

+

Table of contents

+ +
+

Usage

+

To create activities for several users at once check ‘Multiple users activity?’ on the activities form, during creation. From there, select the users to which the activities will be assigned.

+
+
+

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.

+

This module is part of the OCA/social project on GitHub.

+

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

+
+
+
+ + diff --git a/mail_activity_multiple_users/tests/__init__.py b/mail_activity_multiple_users/tests/__init__.py new file mode 100644 index 0000000000..a6f915cde8 --- /dev/null +++ b/mail_activity_multiple_users/tests/__init__.py @@ -0,0 +1 @@ +from . import test_multiple_users diff --git a/mail_activity_multiple_users/tests/test_multiple_users.py b/mail_activity_multiple_users/tests/test_multiple_users.py new file mode 100644 index 0000000000..59ed2140b3 --- /dev/null +++ b/mail_activity_multiple_users/tests/test_multiple_users.py @@ -0,0 +1,81 @@ +# Copyright 2024 Binhex () +# Copyright 2024 Binhex Ariel Barreiros +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +from odoo.tests.common import TransactionCase + + +class TestMailActivityMultipleUsers(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.user = cls.env["res.users"].create( + { + "company_id": cls.env.ref("base.main_company").id, + "name": "User_01", + "login": "user_01", + "email": "user01@company.com", + "groups_id": [ + ( + 6, + 0, + [ + cls.env.ref("base.group_user").id, + cls.env.ref("base.group_partner_manager").id, + ], + ) + ], + } + ) + cls.user2 = cls.env["res.users"].create( + { + "company_id": cls.env.ref("base.main_company").id, + "name": "User_02", + "login": "user_02", + "email": "user02@company.com", + "groups_id": [(6, 0, [cls.env.ref("base.group_user").id])], + } + ) + + cls.contact = cls.env["res.partner"].create( + {"company_id": cls.env.ref("base.main_company").id, "name": "Contact"} + ) + + cls.activity_type = cls.env["mail.activity.type"].create( + { + "name": "Initial Contact", + "delay_count": 0, + "delay_unit": "days", + "res_model": "res.partner", + } + ) + + cls.activity = ( + cls.env["mail.activity"] + .with_user(cls.user) + .create( + { + "activity_type_id": cls.activity_type.id, + "note": "This is a random content for activity", + "res_id": cls.contact.id, + "res_model_id": cls.env.ref("base.model_res_partner").id, + "user_id": cls.user.id, + "is_multiple_users_activity": True, + "user_ids": [(6, 0, [cls.user.id, cls.user2.id])], + } + ) + ) + + def test_activities_created_for_users(self): + user_ids = self.contact.activity_ids.mapped("user_id.id") + self.assertIn(self.user.id, user_ids, "Activity should be created for user") + self.assertIn(self.user2.id, user_ids, "Activity should be created for user2") + + def test_onchange_user_ids(self): + self.activity.user_ids = [(6, 0, [self.user2.id, self.user.id])] + self.activity._onchange_user_ids() + self.assertEqual( + self.activity.user_id.id, + self.user2.id, + "User ID should be set to the first user of user_ids", + ) diff --git a/mail_activity_multiple_users/views/mail_activity_view.xml b/mail_activity_multiple_users/views/mail_activity_view.xml new file mode 100644 index 0000000000..8c74132259 --- /dev/null +++ b/mail_activity_multiple_users/views/mail_activity_view.xml @@ -0,0 +1,30 @@ + + + mail_activity_view_form_popup + + mail.activity + + + {'invisible':['|',('is_multiple_users_activity', '!=', + False),'&',('is_module_calendar_installed', '!=', + False),('activity_category', '=', 'meeting')], + 'required':[('is_multiple_users_activity', '!=', True)]} + + + + + + + + + + diff --git a/setup/mail_activity_multiple_users/odoo/addons/mail_activity_multiple_users b/setup/mail_activity_multiple_users/odoo/addons/mail_activity_multiple_users new file mode 120000 index 0000000000..00b3e317ea --- /dev/null +++ b/setup/mail_activity_multiple_users/odoo/addons/mail_activity_multiple_users @@ -0,0 +1 @@ +../../../../mail_activity_multiple_users \ No newline at end of file diff --git a/setup/mail_activity_multiple_users/setup.py b/setup/mail_activity_multiple_users/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/mail_activity_multiple_users/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)