Skip to content

Commit 2a7e7ca

Browse files
[18.0][MIG] mail_activity_portal: Migration to v18.0 (#228)
* [18.0][MIG] mail_activity_portal: Migration to v18.0 * Update website and author information in manifest * [REM] Removed mail_activity_team and mail_activity_board modules from branch * Update README with testing instructions Added testing instructions for portal activity scheduling. --------- Co-authored-by: jans23 <[email protected]>
1 parent 597c42d commit 2a7e7ca

File tree

5 files changed

+114
-0
lines changed

5 files changed

+114
-0
lines changed

mail_activity_portal/README.rst

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
====================
2+
Mail Activity Portal
3+
====================
4+
This module adds an activity board with form, tree, kanban, calendar, pivot, graph and search views.
5+
6+
7+
Usage
8+
=====
9+
If a messages arrives over the portal an activity for a configured team is scheduled automatically to process the message.
10+
11+
The configuration to add RMA and PO models (Settings --> Technical --> Activity Teams menu)
12+
13+
14+
Testing
15+
=======
16+
17+
Step 1:
18+
19+
1. Go to: "Settings" -> "Users & Companies" -> "Users" -> "+New" button
20+
2. In the "Access Rights" tab, set the "User types" to "Portal"
21+
3. Fill out all other necessary details to create a new testing account
22+
23+
Step 2:
24+
25+
1. Go to: "Settings" -> "Technical" -> "Activities" -> "Activity Teams" -> "+New"
26+
2. Add the "admin account" in the "Members" section
27+
3. Set the "Used models" at least to "Sales Order" (or any other portal-accessible models)
28+
4. Fill out all other necessary details
29+
30+
Step 3:
31+
32+
In this case we are gonna use "Sales Order" as an example.
33+
34+
1. Open a browser window in incognito mode
35+
2. Log into the testing account
36+
3. Purchase an item in the online shop
37+
38+
Step 4:
39+
40+
1. Go back into the admin account and navigate to the "Sales Order" that was made with the testing account.
41+
2. In the chatter panel on the right there should be an automatically generated activity under "Planned Activities"

mail_activity_portal/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
2+
3+
from . import models
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
2+
3+
{
4+
"name": "Mail Activity on Messages over Portal",
5+
"version": "18.0.1.0.0",
6+
"category": "Social Network",
7+
"author": "Nitrokey GmbH",
8+
"website": "https://github.com/Nitrokey/odoo-modules",
9+
"license": "AGPL-3",
10+
"summary": """
11+
* If a messages arrives over the portal an activity for a
12+
configured team is scheduled automatically to process the message
13+
* The configuration to add RMA and PO models
14+
(Settings --> Technical --> Activity Teams menu)
15+
""",
16+
"depends": [
17+
"mail_activity_team",
18+
"portal",
19+
],
20+
"installable": True,
21+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
2+
3+
from . import mail_thread
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
2+
3+
from odoo import models
4+
5+
6+
class MailThread(models.AbstractModel):
7+
_inherit = "mail.thread"
8+
9+
def message_post(self, **kwargs):
10+
"""create activity from portal message"""
11+
msg = super().message_post(**kwargs)
12+
# Call method if from portal
13+
if not self.env.context.get("allowed_company_ids"):
14+
self.schedule_email_activity()
15+
return msg
16+
17+
def schedule_email_activity(self):
18+
# Thread needs mail.activity.mixin
19+
if not self or "activity_ids" not in self._fields:
20+
return
21+
22+
# Skip if there is no team
23+
domain = [("res_model_ids.model", "=", self._name)]
24+
team = self.env["mail.activity.team"].sudo().search(domain, limit=1)
25+
user = team.user_id or team.member_ids
26+
if not team or not user:
27+
return
28+
29+
activity_type = self.env.ref("mail.mail_activity_data_email")
30+
for thread in self:
31+
domain = [
32+
("res_model", "=", thread._name),
33+
("res_id", "=", thread.id),
34+
("automated", "=", True),
35+
("activity_type_id", "=", activity_type.id),
36+
]
37+
if self.env["mail.activity"].search(domain):
38+
continue
39+
40+
# Schedule the new email activity
41+
thread.activity_schedule(
42+
"mail.mail_activity_data_email",
43+
user_id=user[0].id,
44+
team_id=team.id,
45+
automated=True,
46+
)

0 commit comments

Comments
 (0)