diff --git a/mail_activity_partner/README.rst b/mail_activity_partner/README.rst new file mode 100644 index 0000000000..198fe052a0 --- /dev/null +++ b/mail_activity_partner/README.rst @@ -0,0 +1,74 @@ +===================== +Mail Activity Partner +===================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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%2Fsocial-lightgray.png?logo=github + :target: https://github.com/OCA/social/tree/15.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-15-0/social-15-0-mail_activity_partner + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/205/15.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds a partner and commercial partner field to activities + +**Table of contents** + +.. contents:: + :local: + +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 +~~~~~~~ + +* 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..b55240f359 --- /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": "16.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/mail_activity_partner.pot b/mail_activity_partner/i18n/mail_activity_partner.pot new file mode 100644 index 0000000000..3e9a1dcd1a --- /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 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: 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/readme/CONTRIBUTORS.rst b/mail_activity_partner/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..dd53919da1 --- /dev/null +++ b/mail_activity_partner/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Adrià Gil Sorribes (adria.gil@forgeflow.com) +* Joan Mateu Jordi (joan.mateu@forgeflow.com) diff --git a/mail_activity_partner/readme/DESCRIPTION.rst b/mail_activity_partner/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..0a816caa71 --- /dev/null +++ b/mail_activity_partner/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module adds a partner and commercial partner field to activities diff --git a/mail_activity_partner/readme/USAGE.rst b/mail_activity_partner/readme/USAGE.rst new file mode 100644 index 0000000000..e69de29bb2 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..ca8c50b4f3 --- /dev/null +++ b/mail_activity_partner/static/description/index.html @@ -0,0 +1,420 @@ + + + + + + +Mail Activity Partner + + + +
+

Mail Activity Partner

+ + +

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

+

This module adds a partner and commercial partner field to activities

+

Table of contents

+ +
+

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

+
    +
  • 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..45b23ecb4c --- /dev/null +++ b/mail_activity_partner/tests/test_mail_activity_partner.py @@ -0,0 +1,108 @@ +# 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 + + + + + + + + + + diff --git a/setup/mail_activity_partner/odoo/addons/mail_activity_partner b/setup/mail_activity_partner/odoo/addons/mail_activity_partner new file mode 120000 index 0000000000..0b70750ace --- /dev/null +++ b/setup/mail_activity_partner/odoo/addons/mail_activity_partner @@ -0,0 +1 @@ +../../../../mail_activity_partner \ No newline at end of file diff --git a/setup/mail_activity_partner/setup.py b/setup/mail_activity_partner/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/mail_activity_partner/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)