[MIG] 13.0 mail_activity_team

This commit is contained in:
Pedro Gonzalez 2019-11-20 15:39:49 +01:00 committed by Bernat Puig Font
parent 108a4e722f
commit 2ae59d5101
5 changed files with 54 additions and 25 deletions

View File

@ -14,13 +14,13 @@ Mail Activity Team
: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_team
:target: https://github.com/OCA/social/tree/13.0/mail_activity_team
: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_team
:target: https://translation.odoo-community.org/projects/social-13.0/social-13.0-mail_activity_team
: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|
@ -61,7 +61,7 @@ Bug Tracker
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.
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_team%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_team%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.
@ -94,6 +94,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 <https://github.com/OCA/social/tree/12.0/mail_activity_team>`_ project on GitHub.
This module is part of the `OCA/social <https://github.com/OCA/social/tree/13.0/mail_activity_team>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"Language-Team: \n"

View File

@ -57,19 +57,16 @@ class MailActivity(models.Model):
@api.constrains("team_id", "user_id")
def _check_team_and_user(self):
for activity in self:
# SUPERUSER is used to put mail.activity on some objects
# like sale.order coming from stock.picking
# (for example with exception type activity, with no backorder).
# SUPERUSER is inactive and then even if you add it
# to member_ids it's not taken account
# To not be blocked we must add it to constraint condition
if (
activity.user_id.id != SUPERUSER_ID
and activity.team_id
and activity.user_id
and activity.user_id not in self.team_id.member_ids
):
raise ValidationError(
_("The assigned user is not member of " "the team.")
)
# SUPERUSER is used to put mail.activity on some objects
# like sale.order coming from stock.picking
# (for example with exception type activity, with no backorder).
# SUPERUSER is inactive and then even if you add it
# to member_ids it's not taken account
# To not be blocked we must add it to constraint condition
for _activity in self.filtered(
lambda a: a.user_id.id != SUPERUSER_ID
and a.team_id
and a.user_id
and a.user_id not in a.team_id.member_ids
):
raise ValidationError(_("The assigned user is not member of the team."))

View File

@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! 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_team"><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_team"><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_team"><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_team"><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 the possibility to assign teams to activities.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
@ -405,7 +405,7 @@ teams.</p>
<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.
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_team%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_team%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>
</div>
<div class="section" id="credits">
@ -433,7 +433,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
mission is to support the collaborative development of Odoo features and
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_team">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_team">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>
</div>
</div>

View File

@ -115,6 +115,22 @@ class TestMailActivityTeam(TransactionCase):
)
)
self.employee3 = self.env["res.users"].create(
{
"company_id": self.env.ref("base.main_company").id,
"name": "Employee 3",
"login": "csu3",
"email": "crmuser3@yourcompany.com",
"groups_id": [(6, 0, [self.env.ref("base.group_user").id])],
}
)
def test_team_and_user_onchange(self):
with self.assertRaises(ValidationError):
self.team1.member_ids = [(3, self.employee.id)]
self.act2.team_id = self.team1
self.act2.user_id = self.employee
def test_missing_activities(self):
self.assertFalse(self.act1.team_id, "Error: Activity 1 should not have a team.")
self.assertEqual(self.team1.count_missing_activities, 1)
@ -132,6 +148,11 @@ class TestMailActivityTeam(TransactionCase):
self.team2._onchange_member_ids()
self.assertFalse(self.team2.user_id)
def test_leader_onchange(self):
self.team2.user_id = self.employee3
self.team2._onchange_user_id()
self.assertTrue(self.employee3 in self.team2.member_ids)
def test_activity_onchanges(self):
self.assertEqual(
self.act2.team_id, self.team1, "Error: Activity 2 should have Team 1."
@ -147,3 +168,14 @@ class TestMailActivityTeam(TransactionCase):
self.assertEqual(self.act2.team_id, self.team2)
with self.assertRaises(ValidationError):
self.act2.write({"user_id": self.employee2.id, "team_id": self.team1.id})
self.team1.user_id = False
self.act2.user_id = False
self.act2._onchange_user_id()
self.team2.member_ids = [(4, self.employee3.id)]
self.act2.team_id = self.team1
self.act2.team_id = False
self.act2.user_id = self.employee3
self.act2._onchange_user_id()
self.act2.team_id = self.team2
self.team2.member_ids = [(3, self.act2.user_id.id)]
self.act2._onchange_team_id()