From 4d400ce76289f456be9b466d42e39e17b0cfa773 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Gil=20Sorribes?= Date: Fri, 21 Dec 2018 11:00:35 +0100 Subject: [PATCH 01/14] [12.0][ADD] Add module mail_activity_partner [IMP] Change partner_id to a computed field [IMP] Add tests to increase coverage --- mail_activity_partner/README.rst | 73 ++++ mail_activity_partner/__init__.py | 4 + mail_activity_partner/__manifest__.py | 20 + mail_activity_partner/models/__init__.py | 3 + mail_activity_partner/models/mail_activity.py | 36 ++ mail_activity_partner/readme/CONTRIBUTORS.rst | 1 + mail_activity_partner/readme/DESCRIPTION.rst | 1 + mail_activity_partner/readme/USAGE.rst | 0 .../static/description/index.html | 397 ++++++++++++++++++ mail_activity_partner/tests/__init__.py | 3 + .../tests/test_mail_activity_partner.py | 80 ++++ .../views/mail_activity_views.xml | 61 +++ 12 files changed, 679 insertions(+) create mode 100644 mail_activity_partner/README.rst create mode 100644 mail_activity_partner/__init__.py create mode 100644 mail_activity_partner/__manifest__.py create mode 100644 mail_activity_partner/models/__init__.py create mode 100644 mail_activity_partner/models/mail_activity.py create mode 100644 mail_activity_partner/readme/CONTRIBUTORS.rst create mode 100644 mail_activity_partner/readme/DESCRIPTION.rst create mode 100644 mail_activity_partner/readme/USAGE.rst create mode 100644 mail_activity_partner/static/description/index.html create mode 100644 mail_activity_partner/tests/__init__.py create mode 100644 mail_activity_partner/tests/test_mail_activity_partner.py create mode 100644 mail_activity_partner/views/mail_activity_views.xml diff --git a/mail_activity_partner/README.rst b/mail_activity_partner/README.rst new file mode 100644 index 0000000..bda6e60 --- /dev/null +++ b/mail_activity_partner/README.rst @@ -0,0 +1,73 @@ +===================== +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/12.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-12-0/social-12-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/12.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 +~~~~~~~ + +* Eficent + +Contributors +~~~~~~~~~~~~ + +* Adrià Gil Sorribes (adria.gil@eficent.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 0000000..cfc40a3 --- /dev/null +++ b/mail_activity_partner/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import models +from . import tests diff --git a/mail_activity_partner/__manifest__.py b/mail_activity_partner/__manifest__.py new file mode 100644 index 0000000..88013d6 --- /dev/null +++ b/mail_activity_partner/__manifest__.py @@ -0,0 +1,20 @@ +# Copyright 2018 Eficent Business and IT Consulting Services, 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': '12.0.1.0.0', + 'development_status': 'Beta', + 'category': 'Social Network', + 'website': 'https://github.com/OCA/social', + 'author': 'Eficent, 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/models/__init__.py b/mail_activity_partner/models/__init__.py new file mode 100644 index 0000000..4b2923d --- /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 0000000..3e02756 --- /dev/null +++ b/mail_activity_partner/models/mail_activity.py @@ -0,0 +1,36 @@ +# Copyright 2018 Eficent Business and IT Consulting Services, S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from odoo import api, models, fields + + +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 obj in self: + res_model = obj.res_model + res_id = obj.res_id + if res_model == 'res.partner': + obj.partner_id = res_id + else: + res_model_id = obj.env[res_model].search([('id', '=', res_id)]) + if 'partner_id' in res_model_id._fields and \ + res_model_id.partner_id: + obj.partner_id = res_model_id.partner_id + else: + obj.partner_id = None diff --git a/mail_activity_partner/readme/CONTRIBUTORS.rst b/mail_activity_partner/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000..73e229c --- /dev/null +++ b/mail_activity_partner/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Adrià Gil Sorribes (adria.gil@eficent.com) diff --git a/mail_activity_partner/readme/DESCRIPTION.rst b/mail_activity_partner/readme/DESCRIPTION.rst new file mode 100644 index 0000000..0a816ca --- /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 0000000..e69de29 diff --git a/mail_activity_partner/static/description/index.html b/mail_activity_partner/static/description/index.html new file mode 100644 index 0000000..b6d1a5c --- /dev/null +++ b/mail_activity_partner/static/description/index.html @@ -0,0 +1,397 @@ + + + + + + +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

+
    +
  • Eficent
  • +
+
+
+

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 0000000..87bc7cb --- /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 0000000..7c9b4e0 --- /dev/null +++ b/mail_activity_partner/tests/test_mail_activity_partner.py @@ -0,0 +1,80 @@ +# Copyright 2018 Eficent Business and IT Consulting Services, S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from odoo.tests.common import TransactionCase + + +class TestMailActivityPartner(TransactionCase): + + def setUp(self): + super(TestMailActivityPartner, self).setUp() + + self.user_admin = self.env.ref('base.user_root') + + self.employee = self.env['res.users'].create({ + 'company_id': self.env.ref("base.main_company").id, + 'name': "Employee", + 'login': "csu", + 'email': "crmuser@yourcompany.com", + 'groups_id': [(6, 0, [ + self.env.ref('base.group_user').id, + self.env.ref('base.group_partner_manager').id])] + }) + + self.partner_ir_model = self.env['ir.model']._get('res.partner') + + activity_type_model = self.env['mail.activity.type'] + self.activity1 = activity_type_model.create({ + 'name': 'Initial Contact', + 'days': 5, + 'summary': 'ACT 1 : Presentation, barbecue, ... ', + 'res_model_id': self.partner_ir_model.id, + }) + self.activity2 = activity_type_model.create({ + 'name': 'Call for Demo', + 'days': 6, + 'summary': 'ACT 2 : I want to show you my ERP !', + 'res_model_id': self.partner_ir_model.id, + }) + + self.partner_01 = self.env.ref('base.res_partner_1') + + self.homer = self.env['res.partner'].create({ + 'name': 'Homer Simpson', + 'city': 'Springfield', + 'street': '742 Evergreen Terrace', + 'street2': 'Donut Lane', + 'street3': 'Tho', + }) + + # test synchro of street3 on create + self.partner_10 = self.env['res.partner'].create({ + 'name': 'Bart Simpson', + 'parent_id': self.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_ir_model.id, + 'user_id': self.user_admin.id, + }) + + self.act2 = self.env['mail.activity'].sudo(self.employee).create({ + 'activity_type_id': self.activity2.id, + 'note': 'Partner activity 10.', + 'res_id': self.partner_10.id, + 'res_model_id': self.partner_ir_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 0000000..f572e41 --- /dev/null +++ b/mail_activity_partner/views/mail_activity_views.xml @@ -0,0 +1,61 @@ + + + + + + + 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 + + + + + + + + + + From 456164776c92a22211a4ce185e7fa05a8335f377 Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Tue, 15 Jan 2019 08:29:53 +0000 Subject: [PATCH 02/14] [UPD] README.rst --- .../static/description/index.html | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/mail_activity_partner/static/description/index.html b/mail_activity_partner/static/description/index.html index b6d1a5c..9381c19 100644 --- a/mail_activity_partner/static/description/index.html +++ b/mail_activity_partner/static/description/index.html @@ -3,13 +3,13 @@ - + Mail Activity Partner