[MIG] mail_activity_partner: Migration to 13.0

This commit is contained in:
Adrià Gil Sorribes 2019-12-24 11:57:30 +01:00 committed by Joan Mateu Jordi
parent a0374eae05
commit b86ab079c7
6 changed files with 56 additions and 51 deletions

View File

@ -14,13 +14,13 @@ Mail Activity Partner
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3 :alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github .. |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 :alt: OCA/social
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png .. |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 :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png .. |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 :alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
@ -38,7 +38,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/social/issues>`_. Bugs are tracked on `GitHub Issues <https://github.com/OCA/social/issues>`_.
In case of trouble, please check there if your issue has already been reported. 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 If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/social/issues/new?body=module:%20mail_activity_partner%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. `feedback <https://github.com/OCA/social/issues/new?body=module:%20mail_activity_partner%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues. Do not contact contributors directly about support or help with technical issues.
@ -48,12 +48,12 @@ Credits
Authors Authors
~~~~~~~ ~~~~~~~
* Eficent * ForgeFlow
Contributors Contributors
~~~~~~~~~~~~ ~~~~~~~~~~~~
* Adrià Gil Sorribes (adria.gil@eficent.com) * Adrià Gil Sorribes (adria.gil@forgeflow.com)
Maintainers 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 mission is to support the collaborative development of Odoo features and
promote its widespread use. promote its widespread use.
This module is part of the `OCA/social <https://github.com/OCA/social/tree/12.0/mail_activity_partner>`_ project on GitHub. This module is part of the `OCA/social <https://github.com/OCA/social/tree/13.0/mail_activity_partner>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -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). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{ {
"name": "Mail Activity Partner", "name": "Mail Activity Partner",
"summary": "Add Partner to Activities", "summary": "Add Partner to Activities",
"version": "12.0.1.0.0", "version": "13.0.1.0.0",
"development_status": "Beta", "development_status": "Beta",
"category": "Social Network", "category": "Social Network",
"website": "https://github.com/OCA/social", "website": "https://github.com/OCA/social",
"author": "Eficent, Odoo Community Association (OCA)", "author": "ForgeFlow, Odoo Community Association (OCA)",
"license": "AGPL-3", "license": "AGPL-3",
"installable": True, "installable": True,
"data": ["views/mail_activity_views.xml"], "data": ["views/mail_activity_views.xml"],

View File

@ -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). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models from odoo import api, fields, models
@ -23,14 +23,16 @@ class MailActivity(models.Model):
@api.depends("res_model", "res_id") @api.depends("res_model", "res_id")
def _compute_res_partner_id(self): def _compute_res_partner_id(self):
for obj in self: for activity in self:
res_model = obj.res_model res_model = activity.res_model
res_id = obj.res_id res_id = activity.res_id
if res_model == "res.partner": activity.partner_id = False
obj.partner_id = res_id if res_model:
else: if res_model == "res.partner":
res_model_id = obj.env[res_model].search([("id", "=", res_id)]) activity.partner_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: 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

View File

@ -1 +1 @@
* Adrià Gil Sorribes (adria.gil@eficent.com) * Adrià Gil Sorribes (adria.gil@forgeflow.com)

View File

@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/social/tree/12.0/mail_activity_partner"><img alt="OCA/social" src="https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/social-12-0/social-12-0-mail_activity_partner"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/205/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p> <p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/social/tree/13.0/mail_activity_partner"><img alt="OCA/social" src="https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/social-13-0/social-13-0-mail_activity_partner"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/205/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module adds a partner and commercial partner field to activities</p> <p>This module adds a partner and commercial partner field to activities</p>
<p><strong>Table of contents</strong></p> <p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents"> <div class="contents local topic" id="contents">
@ -386,7 +386,7 @@ ul.auto-toc {
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/social/issues">GitHub Issues</a>. <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/social/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported. 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 If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/social/issues/new?body=module:%20mail_activity_partner%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p> <a class="reference external" href="https://github.com/OCA/social/issues/new?body=module:%20mail_activity_partner%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p> <p>Do not contact contributors directly about support or help with technical issues.</p>
</div> </div>
<div class="section" id="credits"> <div class="section" id="credits">
@ -394,13 +394,13 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<div class="section" id="authors"> <div class="section" id="authors">
<h2><a class="toc-backref" href="#id3">Authors</a></h2> <h2><a class="toc-backref" href="#id3">Authors</a></h2>
<ul class="simple"> <ul class="simple">
<li>Eficent</li> <li>ForgeFlow</li>
</ul> </ul>
</div> </div>
<div class="section" id="contributors"> <div class="section" id="contributors">
<h2><a class="toc-backref" href="#id4">Contributors</a></h2> <h2><a class="toc-backref" href="#id4">Contributors</a></h2>
<ul class="simple"> <ul class="simple">
<li>Adrià Gil Sorribes (<a class="reference external" href="mailto:adria.gil&#64;eficent.com">adria.gil&#64;eficent.com</a>)</li> <li>Adrià Gil Sorribes (<a class="reference external" href="mailto:adria.gil&#64;forgeflow.com">adria.gil&#64;forgeflow.com</a>)</li>
</ul> </ul>
</div> </div>
<div class="section" id="maintainers"> <div class="section" id="maintainers">
@ -410,7 +410,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/social/tree/12.0/mail_activity_partner">OCA/social</a> project on GitHub.</p> <p>This module is part of the <a class="reference external" href="https://github.com/OCA/social/tree/13.0/mail_activity_partner">OCA/social</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p> <p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div> </div>
</div> </div>

View File

@ -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). # 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): class TestMailActivityPartner(SavepointCase):
def setUp(self): @classmethod
super(TestMailActivityPartner, self).setUp() 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", "name": "Employee",
"login": "csu", "login": "csu",
"email": "crmuser@yourcompany.com", "email": "crmuser@yourcompany.com",
@ -20,49 +24,48 @@ class TestMailActivityPartner(TransactionCase):
6, 6,
0, 0,
[ [
self.env.ref("base.group_user").id, cls.env.ref("base.group_user").id,
self.env.ref("base.group_partner_manager").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"] activity_type_model = cls.env["mail.activity.type"]
self.activity1 = activity_type_model.create( cls.activity1 = activity_type_model.create(
{ {
"name": "Initial Contact", "name": "Initial Contact",
"days": 5, "delay_count": 5,
"summary": "ACT 1 : Presentation, barbecue, ... ", "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", "name": "Call for Demo",
"days": 6, "delay_count": 6,
"summary": "ACT 2 : I want to show you my ERP !", "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", "name": "Homer Simpson",
"city": "Springfield", "city": "Springfield",
"street": "742 Evergreen Terrace", "street": "742 Evergreen Terrace",
"street2": "Donut Lane", "street2": "Donut Lane",
"street3": "Tho",
} }
) )
# test synchro of street3 on create # test synchro of street3 on create
self.partner_10 = self.env["res.partner"].create( cls.partner_10 = cls.env["res.partner"].create(
{"name": "Bart Simpson", "parent_id": self.homer.id, "type": "contact"} {"name": "Bart Simpson", "parent_id": cls.homer.id, "type": "contact"}
) )
def test_partner_for_activity(self): def test_partner_for_activity(self):
@ -83,7 +86,7 @@ class TestMailActivityPartner(TransactionCase):
self.act2 = ( self.act2 = (
self.env["mail.activity"] self.env["mail.activity"]
.sudo(self.employee) .with_user(self.employee)
.create( .create(
{ {
"activity_type_id": self.activity2.id, "activity_type_id": self.activity2.id,