diff --git a/mail_activity_team/README.rst b/mail_activity_team/README.rst index ae233e3..0b50db6 100644 --- a/mail_activity_team/README.rst +++ b/mail_activity_team/README.rst @@ -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 `_. 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. @@ -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 `_ 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_team/i18n/mail_activity_team.pot b/mail_activity_team/i18n/mail_activity_team.pot index a6173ee..7bc0357 100644 --- a/mail_activity_team/i18n/mail_activity_team.pot +++ b/mail_activity_team/i18n/mail_activity_team.pot @@ -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" diff --git a/mail_activity_team/models/mail_activity.py b/mail_activity_team/models/mail_activity.py index c50f996..b54029d 100644 --- a/mail_activity_team/models/mail_activity.py +++ b/mail_activity_team/models/mail_activity.py @@ -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.")) diff --git a/mail_activity_team/static/description/index.html b/mail_activity_team/static/description/index.html index a48c4f2..94af393 100644 --- a/mail_activity_team/static/description/index.html +++ b/mail_activity_team/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 the possibility to assign teams to activities.

Table of contents

@@ -405,7 +405,7 @@ teams.

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.

@@ -433,7 +433,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_team/tests/test_mail_activity_team.py b/mail_activity_team/tests/test_mail_activity_team.py index 0df444b..8835515 100644 --- a/mail_activity_team/tests/test_mail_activity_team.py +++ b/mail_activity_team/tests/test_mail_activity_team.py @@ -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()