diff --git a/mail_activity_partner/README.rst b/mail_activity_partner/README.rst new file mode 100644 index 0000000000..4f785eabb2 --- /dev/null +++ b/mail_activity_partner/README.rst @@ -0,0 +1,82 @@ +===================== +Mail Activity Partner +===================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:b8f1e18fc30525be3711f60f6ba298b30090661d6884ad6bee0809ccc47a7342 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/17.0/mail_activity_partner + :alt: OCA/social +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/social-17-0/social-17-0-mail_activity_partner + :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=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds a partner and commercial partner field to activities + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + + + +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 +------------ + +- Adrià Gil Sorribes (adria.gil@forgeflow.com) +- Joan Mateu Jordi (joan.mateu@forgeflow.com) + +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_partner/__init__.py b/mail_activity_partner/__init__.py new file mode 100644 index 0000000000..83e553ac46 --- /dev/null +++ b/mail_activity_partner/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import models diff --git a/mail_activity_partner/__manifest__.py b/mail_activity_partner/__manifest__.py new file mode 100644 index 0000000000..1c2b6bb8a3 --- /dev/null +++ b/mail_activity_partner/__manifest__.py @@ -0,0 +1,15 @@ +# Copyright 2018 ForgeFlow S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + "name": "Mail Activity Partner", + "summary": "Add Partner to Activities", + "version": "17.0.1.0.0", + "development_status": "Beta", + "category": "Social Network", + "website": "https://github.com/OCA/social", + "author": "ForgeFlow, Odoo Community Association (OCA)", + "license": "AGPL-3", + "installable": True, + "data": ["views/mail_activity_views.xml"], + "depends": ["mail_activity_board"], +} diff --git a/mail_activity_partner/i18n/es.po b/mail_activity_partner/i18n/es.po new file mode 100644 index 0000000000..44260b852a --- /dev/null +++ b/mail_activity_partner/i18n/es.po @@ -0,0 +1,32 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_activity_partner +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-12-12 16:22+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: mail_activity_partner +#: model:ir.model,name:mail_activity_partner.model_mail_activity +msgid "Activity" +msgstr "Actividad" + +#. module: mail_activity_partner +#: model:ir.model.fields,field_description:mail_activity_partner.field_mail_activity__commercial_partner_id +msgid "Commercial Entity" +msgstr "Entidad Comercial" + +#. module: mail_activity_partner +#: model:ir.model.fields,field_description:mail_activity_partner.field_mail_activity__partner_id +msgid "Partner" +msgstr "Proveedor" diff --git a/mail_activity_partner/i18n/it.po b/mail_activity_partner/i18n/it.po new file mode 100644 index 0000000000..08005cf63f --- /dev/null +++ b/mail_activity_partner/i18n/it.po @@ -0,0 +1,32 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_activity_partner +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-12-01 10:12+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: mail_activity_partner +#: model:ir.model,name:mail_activity_partner.model_mail_activity +msgid "Activity" +msgstr "Attività" + +#. module: mail_activity_partner +#: model:ir.model.fields,field_description:mail_activity_partner.field_mail_activity__commercial_partner_id +msgid "Commercial Entity" +msgstr "Entità commerciale" + +#. module: mail_activity_partner +#: model:ir.model.fields,field_description:mail_activity_partner.field_mail_activity__partner_id +msgid "Partner" +msgstr "Partner" diff --git a/mail_activity_partner/i18n/mail_activity_partner.pot b/mail_activity_partner/i18n/mail_activity_partner.pot new file mode 100644 index 0000000000..d44cd5b19b --- /dev/null +++ b/mail_activity_partner/i18n/mail_activity_partner.pot @@ -0,0 +1,29 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_activity_partner +# +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: mail_activity_partner +#: model:ir.model,name:mail_activity_partner.model_mail_activity +msgid "Activity" +msgstr "" + +#. module: mail_activity_partner +#: model:ir.model.fields,field_description:mail_activity_partner.field_mail_activity__commercial_partner_id +msgid "Commercial Entity" +msgstr "" + +#. module: mail_activity_partner +#: model:ir.model.fields,field_description:mail_activity_partner.field_mail_activity__partner_id +msgid "Partner" +msgstr "" diff --git a/mail_activity_partner/models/__init__.py b/mail_activity_partner/models/__init__.py new file mode 100644 index 0000000000..4b2923d3c3 --- /dev/null +++ b/mail_activity_partner/models/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import mail_activity diff --git a/mail_activity_partner/models/mail_activity.py b/mail_activity_partner/models/mail_activity.py new file mode 100644 index 0000000000..f46fe53eef --- /dev/null +++ b/mail_activity_partner/models/mail_activity.py @@ -0,0 +1,38 @@ +# Copyright 2018 ForgeFlow S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from odoo import api, fields, models + + +class MailActivity(models.Model): + _inherit = "mail.activity" + + partner_id = fields.Many2one( + comodel_name="res.partner", + index=True, + compute="_compute_res_partner_id", + store=True, + ) + + commercial_partner_id = fields.Many2one( + related="partner_id.commercial_partner_id", + string="Commercial Entity", + store=True, + related_sudo=True, + readonly=True, + ) + + @api.depends("res_model", "res_id") + def _compute_res_partner_id(self): + for activity in self: + res_model = activity.res_model + res_id = activity.res_id + activity.partner_id = False + if res_model: + if res_model == "res.partner": + activity.partner_id = res_id + else: + res_model_id = self.env[res_model].browse(res_id) + if "partner_id" in res_model_id._fields and res_model_id.partner_id: + activity.partner_id = res_model_id.partner_id + else: + activity.partner_id = False diff --git a/mail_activity_partner/pyproject.toml b/mail_activity_partner/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/mail_activity_partner/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/mail_activity_partner/readme/CONTRIBUTORS.md b/mail_activity_partner/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..de08763345 --- /dev/null +++ b/mail_activity_partner/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- Adrià Gil Sorribes () +- Joan Mateu Jordi () diff --git a/mail_activity_partner/readme/DESCRIPTION.md b/mail_activity_partner/readme/DESCRIPTION.md new file mode 100644 index 0000000000..0a816caa71 --- /dev/null +++ b/mail_activity_partner/readme/DESCRIPTION.md @@ -0,0 +1 @@ +This module adds a partner and commercial partner field to activities diff --git a/mail_activity_partner/readme/USAGE.md b/mail_activity_partner/readme/USAGE.md new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/mail_activity_partner/readme/USAGE.md @@ -0,0 +1 @@ + diff --git a/mail_activity_partner/static/description/icon.png b/mail_activity_partner/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/mail_activity_partner/static/description/icon.png differ diff --git a/mail_activity_partner/static/description/index.html b/mail_activity_partner/static/description/index.html new file mode 100644 index 0000000000..b33259d9ba --- /dev/null +++ b/mail_activity_partner/static/description/index.html @@ -0,0 +1,428 @@ + + + + + +Mail Activity Partner + + + +
+

Mail Activity Partner

+ + +

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

+

This module adds a partner and commercial partner field to activities

+

Table of contents

+ +
+

Usage

+
+
+

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

+ +
+
+

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_partner/tests/__init__.py b/mail_activity_partner/tests/__init__.py new file mode 100644 index 0000000000..87bc7cbfbe --- /dev/null +++ b/mail_activity_partner/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import test_mail_activity_partner diff --git a/mail_activity_partner/tests/test_mail_activity_partner.py b/mail_activity_partner/tests/test_mail_activity_partner.py new file mode 100644 index 0000000000..ddee23259a --- /dev/null +++ b/mail_activity_partner/tests/test_mail_activity_partner.py @@ -0,0 +1,107 @@ +# Copyright 2018 ForgeFlow S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from odoo.tests.common import TransactionCase + + +class TestMailActivityPartner(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + # disable tracking test suite wise + cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) + cls.user_model = cls.env["res.users"].with_context(no_reset_password=True) + + cls.user_admin = cls.env.ref("base.user_root") + + cls.employee = cls.env["res.users"].create( + { + "company_id": cls.env.ref("base.main_company").id, + "name": "Employee", + "login": "csu", + "email": "crmuser@yourcompany.com", + "groups_id": [ + ( + 6, + 0, + [ + cls.env.ref("base.group_user").id, + cls.env.ref("base.group_partner_manager").id, + ], + ) + ], + } + ) + + cls.partner_model = cls.env["ir.model"]._get("res.partner") + + activity_type_model = cls.env["mail.activity.type"] + cls.activity1 = activity_type_model.create( + { + "name": "Initial Contact", + "delay_count": 5, + "delay_unit": "days", + "summary": "ACT 1 : Presentation, barbecue, ... ", + "res_model": cls.partner_model.model, + } + ) + cls.activity2 = activity_type_model.create( + { + "name": "Call for Demo", + "delay_count": 6, + "summary": "ACT 2 : I want to show you my ERP !", + "res_model": cls.partner_model.model, + } + ) + + cls.partner_01 = cls.env.ref("base.res_partner_1") + + cls.homer = cls.env["res.partner"].create( + { + "name": "Homer Simpson", + "city": "Springfield", + "street": "742 Evergreen Terrace", + "street2": "Donut Lane", + } + ) + + # test synchro of street3 on create + cls.partner_10 = cls.env["res.partner"].create( + {"name": "Bart Simpson", "parent_id": cls.homer.id, "type": "contact"} + ) + + def test_partner_for_activity(self): + self.act1 = ( + self.env["mail.activity"] + .sudo() + .create( + { + "activity_type_id": self.activity1.id, + "note": "Partner activity 1.", + "res_id": self.partner_01.id, + "res_model_id": self.partner_model.id, + "user_id": self.user_admin.id, + } + ) + ) + + self.act2 = ( + self.env["mail.activity"] + .with_user(self.employee) + .create( + { + "activity_type_id": self.activity2.id, + "note": "Partner activity 10.", + "res_id": self.partner_10.id, + "res_model_id": self.partner_model.id, + "user_id": self.employee.id, + } + ) + ) + + # Check partner_id of created activities + self.assertEqual(self.act1.partner_id, self.partner_01) + self.assertEqual(self.act2.partner_id, self.partner_10) + + # Check commercial_partner_id for created activities + self.assertEqual(self.act1.commercial_partner_id, self.partner_01) + self.assertEqual(self.act2.commercial_partner_id, self.homer) diff --git a/mail_activity_partner/views/mail_activity_views.xml b/mail_activity_partner/views/mail_activity_views.xml new file mode 100644 index 0000000000..c568664f25 --- /dev/null +++ b/mail_activity_partner/views/mail_activity_views.xml @@ -0,0 +1,64 @@ + + + + + + + mail.activity.boards.view.form + mail.activity + + + + + + + + + + + + + mail.activity.boards.view.tree + mail.activity + + + + + + + + + + + + + mail.activity.boards.view.kanban + mail.activity + + + + + + + + + + + + mail.activity.boards.view.search + mail.activity + + + + + + + + + +