Skip to content

Commit 5fe7b94

Browse files
committed
[MIG] mail_activity_team: Initial setup for migration to 19.0
1 parent 99b4647 commit 5fe7b94

File tree

11 files changed

+33
-78
lines changed

11 files changed

+33
-78
lines changed

mail_activity_team/README.rst

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ Mail Activity Team
2121
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
2222
:alt: License: AGPL-3
2323
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmail-lightgray.png?logo=github
24-
:target: https://github.com/OCA/mail/tree/18.0/mail_activity_team
24+
:target: https://github.com/OCA/mail/tree/19.0/mail_activity_team
2525
:alt: OCA/mail
2626
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
27-
:target: https://translation.odoo-community.org/projects/mail-18-0/mail-18-0-mail_activity_team
27+
:target: https://translation.odoo-community.org/projects/mail-19-0/mail-19-0-mail_activity_team
2828
:alt: Translate me on Weblate
2929
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
30-
:target: https://runboat.odoo-community.org/builds?repo=OCA/mail&target_branch=18.0
30+
:target: https://runboat.odoo-community.org/builds?repo=OCA/mail&target_branch=19.0
3131
:alt: Try me on Runboat
3232

3333
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -65,7 +65,7 @@ Bug Tracker
6565
Bugs are tracked on `GitHub Issues <https://github.com/OCA/mail/issues>`_.
6666
In case of trouble, please check there if your issue has already been reported.
6767
If you spotted it first, help us to smash it by providing a detailed and welcomed
68-
`feedback <https://github.com/OCA/mail/issues/new?body=module:%20mail_activity_team%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
68+
`feedback <https://github.com/OCA/mail/issues/new?body=module:%20mail_activity_team%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
6969

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

@@ -114,8 +114,7 @@ Contributors
114114
Other credits
115115
-------------
116116

117-
The migration of this module from 16.0 to 17.0 was financially supported
118-
by Camptocamp
117+
119118

120119
Maintainers
121120
-----------
@@ -130,6 +129,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
130129
mission is to support the collaborative development of Odoo features and
131130
promote its widespread use.
132131

133-
This module is part of the `OCA/mail <https://github.com/OCA/mail/tree/18.0/mail_activity_team>`_ project on GitHub.
132+
This module is part of the `OCA/mail <https://github.com/OCA/mail/tree/19.0/mail_activity_team>`_ project on GitHub.
134133

135134
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

mail_activity_team/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{
66
"name": "Mail Activity Team",
77
"summary": "Add Teams to Activities",
8-
"version": "18.0.1.0.3",
8+
"version": "19.0.1.0.0",
99
"development_status": "Beta",
1010
"category": "Social Network",
1111
"website": "https://github.com/OCA/mail",

mail_activity_team/migrations/18.0.1.0.0/post-migration.py

Lines changed: 0 additions & 9 deletions
This file was deleted.

mail_activity_team/models/mail_activity.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright 2018-22 ForgeFlow S.L.
22
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
33

4-
from odoo import SUPERUSER_ID, _, api, fields, models
4+
from odoo import api, fields, models
55
from odoo.exceptions import ValidationError
66

77

@@ -81,14 +81,14 @@ def _check_team_and_user(self):
8181
# We must consider also users that could be archived but come from
8282
# an automatic scheduled activity
8383
if (
84-
activity.user_id.id != SUPERUSER_ID
84+
activity.user_id.id != api.SUPERUSER_ID
8585
and activity.team_id
8686
and activity.user_id
8787
and activity.user_id
8888
not in activity.team_id.with_context(active_test=False).member_ids
8989
):
9090
raise ValidationError(
91-
_(
91+
self.env._(
9292
"The assigned user %(user_name)s is "
9393
"not member of the team %(team_name)s.",
9494
user_name=activity.user_id.name,

mail_activity_team/models/mail_activity_mixin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def _compute_activity_team_user_ids(self):
1919
rec.activity_team_user_ids = rec.activity_ids.mapped("team_id.member_ids")
2020

2121
def _search_my_activity_date_deadline(self, operator, operand):
22-
if not self._context.get("team_activities", False):
22+
if not self.env.context.get("team_activities", False):
2323
return super()._search_my_activity_date_deadline(operator, operand)
2424
activity_ids = self.env["mail.activity"]._search(
2525
[
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
The migration of this module from 16.0 to 17.0 was financially supported by Camptocamp

mail_activity_team/static/description/index.html

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ <h1>Mail Activity Team</h1>
374374
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
375375
!! source digest: sha256:ca0203ad2f0fed4e4686b319424332ac44446e2380683a802c1052f78584cfa4
376376
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
377-
<p><a class="reference external image-reference" 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 image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/mail/tree/18.0/mail_activity_team"><img alt="OCA/mail" src="https://img.shields.io/badge/github-OCA%2Fmail-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/mail-18-0/mail-18-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 image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/mail&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
377+
<p><a class="reference external image-reference" 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 image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/mail/tree/19.0/mail_activity_team"><img alt="OCA/mail" src="https://img.shields.io/badge/github-OCA%2Fmail-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/mail-19-0/mail-19-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 image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/mail&amp;target_branch=19.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
378378
<p>This module adds the possibility to assign teams to activities.</p>
379379
<p><strong>Table of contents</strong></p>
380380
<div class="contents local topic" id="contents">
@@ -412,7 +412,7 @@ <h2><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h2>
412412
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/mail/issues">GitHub Issues</a>.
413413
In case of trouble, please check there if your issue has already been reported.
414414
If you spotted it first, help us to smash it by providing a detailed and welcomed
415-
<a class="reference external" href="https://github.com/OCA/mail/issues/new?body=module:%20mail_activity_team%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
415+
<a class="reference external" href="https://github.com/OCA/mail/issues/new?body=module:%20mail_activity_team%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
416416
<p>Do not contact contributors directly about support or help with technical issues.</p>
417417
</div>
418418
<div class="section" id="credits">
@@ -460,8 +460,6 @@ <h3><a class="toc-backref" href="#toc-entry-5">Contributors</a></h3>
460460
</div>
461461
<div class="section" id="other-credits">
462462
<h3><a class="toc-backref" href="#toc-entry-6">Other credits</a></h3>
463-
<p>The migration of this module from 16.0 to 17.0 was financially supported
464-
by Camptocamp</p>
465463
</div>
466464
<div class="section" id="maintainers">
467465
<h3><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h3>
@@ -472,7 +470,7 @@ <h3><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h3>
472470
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
473471
mission is to support the collaborative development of Odoo features and
474472
promote its widespread use.</p>
475-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/mail/tree/18.0/mail_activity_team">OCA/mail</a> project on GitHub.</p>
473+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/mail/tree/19.0/mail_activity_team">OCA/mail</a> project on GitHub.</p>
476474
<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>
477475
</div>
478476
</div>

mail_activity_team/static/src/core/web/activity.xml

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,6 @@
66
t-inherit="mail.Activity"
77
t-inherit-mode="extension"
88
>
9-
<!-- Prevent error rendering the avatar in case of missing user -->
10-
<xpath
11-
expr="//div/div[hasclass('o-mail-Activity-sidebar')]/a/img"
12-
position="attributes"
13-
>
14-
<attribute name="t-if">props.activity.user_id</attribute>
15-
</xpath>
16-
<!-- Prevent error rendering the assigned user in case of missing user -->
17-
<xpath
18-
expr="//div/div/div[hasclass('o-mail-Activity-info')]/span[hasclass('o-mail-Activity-user')]"
19-
position="attributes"
20-
>
21-
<attribute name="t-if">props.activity.user_id</attribute>
22-
</xpath>
239
<!-- Show team in the condensed view -->
2410
<xpath
2511
expr="//div/div/div[hasclass('o-mail-Activity-info')]/span[hasclass('o-mail-Activity-user')]"
@@ -31,16 +17,9 @@
3117
>(Team <t t-esc="props.activity.team_id[1]" />)
3218
</span>
3319
</xpath>
34-
<!-- Prevent error rendering the assigned user in case of missing user in the expanded view -->
35-
<xpath
36-
expr="//t[@t-esc='props.activity.persona.name']/parent::td/parent::tr"
37-
position="attributes"
38-
>
39-
<attribute name="t-if">props.activity.user_id</attribute>
40-
</xpath>
4120
<!-- Show team in the expanded view -->
4221
<xpath
43-
expr="//t[@t-esc='props.activity.persona.name']/parent::td/parent::tr"
22+
expr="//t[@t-esc='props.activity.user_id.name']/parent::td/parent::tr"
4423
position="after"
4524
>
4625
<tr t-if="props.activity.team_id">

mail_activity_team/static/src/models/activity_menu.esm.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
import {ActivityMenu} from "@mail/core/web/activity_menu";
22
import {patch} from "@web/core/utils/patch";
33
import {useRef} from "@odoo/owl";
4+
import {useService} from "@web/core/utils/hooks";
45
import {user} from "@web/core/user";
56

67
patch(ActivityMenu.prototype, {
78
setup() {
89
super.setup();
910
this.currentFilter = "my";
1011
this.rootRef = useRef("mail_activity_team_dropdown");
12+
this.store = useService("mail.store");
1113
},
1214
activateFilter(filter_el) {
1315
this.deactivateButtons();
1416

1517
filter_el.classList.add("active");
1618
this.currentFilter = filter_el.dataset.filter;
1719
this.updateTeamActivitiesContext();
18-
this.store.fetchData({systray_get_activities: true});
20+
this.store.fetchStoreData("systray_get_activities");
1921
},
2022
updateTeamActivitiesContext() {
2123
var active = false;
@@ -30,7 +32,9 @@ patch(ActivityMenu.prototype, {
3032
},
3133

3234
deactivateButtons() {
33-
this.rootRef.el.querySelector(".o_filter_nav_item").classList.remove("active");
35+
this.rootRef.el.querySelectorAll(".o_filter_nav_item").forEach((el) => {
36+
el.classList.remove("active");
37+
});
3438
},
3539
onClickActivityFilter(filter) {
3640
this.activateFilter(this.rootRef.el.querySelector("." + filter));

mail_activity_team/tests/test_mail_activity_team.py

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
# Copyright 2018-22 ForgeFlow S.L.
22
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3-
import os
43
from datetime import date
54

65
from odoo.exceptions import ValidationError
7-
from odoo.modules.migration import load_script
86
from odoo.tests import Form
97
from odoo.tests.common import TransactionCase
108

@@ -23,7 +21,7 @@ def setUpClass(cls):
2321
"name": "Employee",
2422
"login": "csu",
2523
"email": "crmuser@yourcompany.com",
26-
"groups_id": [
24+
"group_ids": [
2725
(
2826
6,
2927
0,
@@ -41,7 +39,7 @@ def setUpClass(cls):
4139
"name": "Employee 2",
4240
"login": "csu2",
4341
"email": "crmuser2@yourcompany.com",
44-
"groups_id": [(6, 0, [cls.env.ref("base.group_user").id])],
42+
"group_ids": [(6, 0, [cls.env.ref("base.group_user").id])],
4543
}
4644
)
4745
cls.employee3 = cls.env["res.users"].create(
@@ -50,7 +48,7 @@ def setUpClass(cls):
5048
"name": "Employee 3",
5149
"login": "csu3",
5250
"email": "crmuser3@yourcompany.com",
53-
"groups_id": [(6, 0, [cls.env.ref("base.group_user").id])],
51+
"group_ids": [(6, 0, [cls.env.ref("base.group_user").id])],
5452
}
5553
)
5654
# Create Activity Types
@@ -73,7 +71,11 @@ def setUpClass(cls):
7371
}
7472
)
7573
# Create Teams and Activities
76-
cls.partner_client = cls.env.ref("base.res_partner_1")
74+
cls.partner_client = cls.env["res.partner"].create(
75+
{
76+
"name": "Test Client",
77+
}
78+
)
7779
cls.partner_ir_model = cls.env["ir.model"]._get("res.partner")
7880
cls.act1 = (
7981
cls.env["mail.activity"]
@@ -298,7 +300,8 @@ def test_activity_count(self):
298300
self.assertEqual(res[0]["total_count"], 1)
299301
self.assertEqual(res[0]["today_count"], 2)
300302
res = self.env["res.users"].with_user(self.employee.id)._get_activity_groups()
301-
self.assertEqual(res[0]["total_count"], 2)
303+
# In v19 _get_activity_groups() function, groups count for each state.
304+
self.assertEqual(res[0]["total_count"], 1)
302305

303306
def test_activity_schedule_next(self):
304307
self.activity1.write(
@@ -393,7 +396,7 @@ def test_web_search_read(self):
393396
# Create a non-team activity for our second employee, for a second partner
394397
self.team1.member_ids |= self.employee2
395398
partner2 = self.partner_client.copy()
396-
self.employee2.groups_id += self.env.ref("base.group_partner_manager")
399+
self.employee2.group_ids += self.env.ref("base.group_partner_manager")
397400

398401
# Craft the activity without a team
399402
act3 = (
@@ -429,21 +432,3 @@ def test_web_search_read(self):
429432
),
430433
set(self.partner_client.ids),
431434
)
432-
433-
def test_migration(self):
434-
"""Check that the 18.0.1.0.0 migration script runs without error"""
435-
rule = self.env.ref("mail_activity_team.mail_activity_rule_my_team")
436-
rule.perm_create = True
437-
438-
# Run the migration script
439-
pyfile = os.path.join(
440-
"mail_activity_team",
441-
"migrations",
442-
"18.0.1.0.0",
443-
"post-migration.py",
444-
)
445-
name, ext = os.path.splitext(os.path.basename(pyfile))
446-
mod = load_script(pyfile, name)
447-
mod.migrate(self.env.cr, "18.0.1.0.0")
448-
449-
self.assertFalse(rule.perm_create)

0 commit comments

Comments
 (0)