From b86ab079c72f800d84414ce271f0635205e0b4bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Gil=20Sorribes?= Date: Tue, 24 Dec 2019 11:57:30 +0100 Subject: [PATCH] [MIG] mail_activity_partner: Migration to 13.0 --- mail_activity_partner/README.rst | 14 ++--- mail_activity_partner/__manifest__.py | 6 +-- mail_activity_partner/models/mail_activity.py | 24 +++++---- mail_activity_partner/readme/CONTRIBUTORS.rst | 2 +- .../static/description/index.html | 10 ++-- .../tests/test_mail_activity_partner.py | 51 ++++++++++--------- 6 files changed, 56 insertions(+), 51 deletions(-) diff --git a/mail_activity_partner/README.rst b/mail_activity_partner/README.rst index bda6e60..9048d27 100644 --- a/mail_activity_partner/README.rst +++ b/mail_activity_partner/README.rst @@ -14,13 +14,13 @@ Mail Activity Partner :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 + :target: https://github.com/OCA/social/tree/13.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 + :target: https://translation.odoo-community.org/projects/social-13-0/social-13-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 + :target: https://runbot.odoo-community.org/runbot/205/13.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -38,7 +38,7 @@ 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -48,12 +48,12 @@ Credits Authors ~~~~~~~ -* Eficent +* ForgeFlow Contributors ~~~~~~~~~~~~ -* Adrià Gil Sorribes (adria.gil@eficent.com) +* Adrià Gil Sorribes (adria.gil@forgeflow.com) Maintainers ~~~~~~~~~~~ @@ -68,6 +68,6 @@ 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. +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/__manifest__.py b/mail_activity_partner/__manifest__.py index 161b036..6d36678 100644 --- a/mail_activity_partner/__manifest__.py +++ b/mail_activity_partner/__manifest__.py @@ -1,13 +1,13 @@ -# Copyright 2018 Eficent Business and IT Consulting Services, S.L. +# 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": "12.0.1.0.0", + "version": "13.0.1.0.0", "development_status": "Beta", "category": "Social Network", "website": "https://github.com/OCA/social", - "author": "Eficent, Odoo Community Association (OCA)", + "author": "ForgeFlow, Odoo Community Association (OCA)", "license": "AGPL-3", "installable": True, "data": ["views/mail_activity_views.xml"], diff --git a/mail_activity_partner/models/mail_activity.py b/mail_activity_partner/models/mail_activity.py index 57b305c..f46fe53 100644 --- a/mail_activity_partner/models/mail_activity.py +++ b/mail_activity_partner/models/mail_activity.py @@ -1,4 +1,4 @@ -# Copyright 2018 Eficent Business and IT Consulting Services, S.L. +# Copyright 2018 ForgeFlow S.L. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from odoo import api, fields, models @@ -23,14 +23,16 @@ class MailActivity(models.Model): @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 + 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: - obj.partner_id = None + 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 index 73e229c..5e81a9b 100644 --- a/mail_activity_partner/readme/CONTRIBUTORS.rst +++ b/mail_activity_partner/readme/CONTRIBUTORS.rst @@ -1 +1 @@ -* Adrià Gil Sorribes (adria.gil@eficent.com) +* Adrià Gil Sorribes (adria.gil@forgeflow.com) diff --git a/mail_activity_partner/static/description/index.html b/mail_activity_partner/static/description/index.html index b73364d..c7dc1d8 100644 --- a/mail_activity_partner/static/description/index.html +++ b/mail_activity_partner/static/description/index.html @@ -367,7 +367,7 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

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

+

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

@@ -386,7 +386,7 @@ ul.auto-toc {

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.

+feedback.

Do not contact contributors directly about support or help with technical issues.

@@ -394,13 +394,13 @@ If you spotted it first, help us smashing it by providing a detailed and welcome

Authors

    -
  • Eficent
  • +
  • ForgeFlow

Contributors

@@ -410,7 +410,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome

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.

+

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/test_mail_activity_partner.py b/mail_activity_partner/tests/test_mail_activity_partner.py index df086b7..30c7c1a 100644 --- a/mail_activity_partner/tests/test_mail_activity_partner.py +++ b/mail_activity_partner/tests/test_mail_activity_partner.py @@ -1,17 +1,21 @@ -# Copyright 2018 Eficent Business and IT Consulting Services, S.L. +# Copyright 2018 ForgeFlow S.L. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo.tests.common import TransactionCase +from odoo.tests.common import SavepointCase -class TestMailActivityPartner(TransactionCase): - def setUp(self): - super(TestMailActivityPartner, self).setUp() +class TestMailActivityPartner(SavepointCase): + @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) - self.user_admin = self.env.ref("base.user_root") + cls.user_admin = cls.env.ref("base.user_root") - self.employee = self.env["res.users"].create( + cls.employee = cls.env["res.users"].create( { - "company_id": self.env.ref("base.main_company").id, + "company_id": cls.env.ref("base.main_company").id, "name": "Employee", "login": "csu", "email": "crmuser@yourcompany.com", @@ -20,49 +24,48 @@ class TestMailActivityPartner(TransactionCase): 6, 0, [ - self.env.ref("base.group_user").id, - self.env.ref("base.group_partner_manager").id, + cls.env.ref("base.group_user").id, + cls.env.ref("base.group_partner_manager").id, ], ) ], } ) - self.partner_ir_model = self.env["ir.model"]._get("res.partner") + cls.partner_ir_model = cls.env["ir.model"]._get("res.partner") - activity_type_model = self.env["mail.activity.type"] - self.activity1 = activity_type_model.create( + activity_type_model = cls.env["mail.activity.type"] + cls.activity1 = activity_type_model.create( { "name": "Initial Contact", - "days": 5, + "delay_count": 5, "summary": "ACT 1 : Presentation, barbecue, ... ", - "res_model_id": self.partner_ir_model.id, + "res_model_id": cls.partner_ir_model.id, } ) - self.activity2 = activity_type_model.create( + cls.activity2 = activity_type_model.create( { "name": "Call for Demo", - "days": 6, + "delay_count": 6, "summary": "ACT 2 : I want to show you my ERP !", - "res_model_id": self.partner_ir_model.id, + "res_model_id": cls.partner_ir_model.id, } ) - self.partner_01 = self.env.ref("base.res_partner_1") + cls.partner_01 = cls.env.ref("base.res_partner_1") - self.homer = self.env["res.partner"].create( + cls.homer = cls.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"} + cls.partner_10 = cls.env["res.partner"].create( + {"name": "Bart Simpson", "parent_id": cls.homer.id, "type": "contact"} ) def test_partner_for_activity(self): @@ -83,7 +86,7 @@ class TestMailActivityPartner(TransactionCase): self.act2 = ( self.env["mail.activity"] - .sudo(self.employee) + .with_user(self.employee) .create( { "activity_type_id": self.activity2.id,