Skip to content

Commit

Permalink
[MIG] mail_tracking: migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
payen000 committed Sep 6, 2023
1 parent 4032e60 commit dd63684
Show file tree
Hide file tree
Showing 25 changed files with 602 additions and 609 deletions.
22 changes: 6 additions & 16 deletions mail_tracking/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{
"name": "Email tracking",
"summary": "Email tracking system for all mails sent",
"version": "15.0.3.1.0",
"version": "16.0.1.0.0",
"category": "Social Network",
"website": "https://github.com/OCA/social",
"author": ("Tecnativa, " "Odoo Community Association (OCA)"),
Expand All @@ -27,21 +27,11 @@
],
"assets": {
"web.assets_backend": [
"mail_tracking/static/src/css/mail_tracking.scss",
"mail_tracking/static/src/css/failed_message.scss",
"mail_tracking/static/src/js/mail_tracking.esm.js",
"mail_tracking/static/src/js/message.esm.js",
"mail_tracking/static/src/js/failed_message/mail_failed_box.esm.js",
"mail_tracking/static/src/js/failed_message/thread.esm.js",
"mail_tracking/static/src/js/models/thread.esm.js",
"mail_tracking/static/src/js/chatter.esm.js",
"mail_tracking/static/src/js/discuss/discuss.esm.js",
],
"web.assets_qweb": [
"mail_tracking/static/src/xml/mail_tracking.xml",
"mail_tracking/static/src/xml/failed_message/common.xml",
"mail_tracking/static/src/xml/failed_message/thread.xml",
"mail_tracking/static/src/xml/failed_message/discuss.xml",
"mail_tracking/static/src/css/*.scss",
"mail_tracking/static/src/js/models/*.esm.js",
"mail_tracking/static/src/js/*.esm.js",
"mail_tracking/static/src/components/*.xml",
"mail_tracking/static/src/components/*.esm.js",
],
},
"demo": ["demo/demo.xml"],
Expand Down
14 changes: 9 additions & 5 deletions mail_tracking/controllers/discuss.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ def mail_init_messaging(self):

@http.route("/mail/failed/messages", methods=["POST"], type="json", auth="user")
def discuss_failed_messages(self, max_id=None, min_id=None, limit=30, **kwargs):
return http.request.env["mail.message"]._message_fetch(
domain=[("is_failed_message", "=", True)],
max_id=max_id,
min_id=min_id,
limit=limit,
return (
http.request.env["mail.message"]
._message_fetch(
domain=[("is_failed_message", "=", True)],
max_id=max_id,
min_id=min_id,
limit=limit,
)
.message_format()
)
28 changes: 20 additions & 8 deletions mail_tracking/demo/demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@
<field name="body"><![CDATA[<p>This is a message with CC</p>]]></field>
<field name="email_from">[email protected]</field>
<field name="author_id" ref="base.res_partner_1" />
<field name="partner_ids" eval="[(6, 0, [ref('base.partner_demo')])]" />
<field
name="partner_ids"
eval="[Command.set([ref('base.partner_demo')])]"
/>
<field
name="notification_ids"
eval="[(0, 0, {'res_partner_id': ref('base.partner_demo')})]"
eval="[Command.create({'res_partner_id': ref('base.partner_demo')})]"
/>
<field name="subject">Message with CC</field>
</record>
Expand All @@ -41,10 +44,13 @@
<field name="body"><![CDATA[<p>This is a failed message</p>]]></field>
<field name="email_from">[email protected]</field>
<field name="author_id" ref="base.res_partner_1" />
<field name="partner_ids" eval="[(6, 0, [ref('base.partner_demo')])]" />
<field
name="partner_ids"
eval="[Command.set([ref('base.partner_demo')])]"
/>
<field
name="notification_ids"
eval="[(0, 0, {'res_partner_id': ref('base.partner_demo')})]"
eval="[Command.create({'res_partner_id': ref('base.partner_demo')})]"
/>
<field name="subject">Failed Message</field>
</record>
Expand All @@ -69,10 +75,13 @@
<field name="body"><![CDATA[<p>This is another failed message</p>]]></field>
<field name="email_from">[email protected]</field>
<field name="author_id" ref="base.res_partner_10" />
<field name="partner_ids" eval="[(6, 0, [ref('base.partner_demo')])]" />
<field
name="partner_ids"
eval="[Command.set([ref('base.partner_demo')])]"
/>
<field
name="notification_ids"
eval="[(0, 0, {'res_partner_id': ref('base.partner_demo')})]"
eval="[Command.create({'res_partner_id': ref('base.partner_demo')})]"
/>
<field name="subject">Failed Message</field>
</record>
Expand All @@ -97,10 +106,13 @@
<field name="body"><![CDATA[<p>This is another failed message</p>]]></field>
<field name="email_from">[email protected]</field>
<field name="author_id" ref="base.partner_admin" />
<field name="partner_ids" eval="[(6, 0, [ref('base.partner_demo')])]" />
<field
name="partner_ids"
eval="[Command.set([ref('base.partner_demo')])]"
/>
<field
name="notification_ids"
eval="[(0, 0, {'res_partner_id': ref('base.partner_demo')})]"
eval="[Command.create({'res_partner_id': ref('base.partner_demo')})]"
/>
<field name="subject">Failed Message</field>
</record>
Expand Down
8 changes: 2 additions & 6 deletions mail_tracking/models/mail_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,13 @@ def _add_extra_recipients_suggestions(self, suggestions, field_mail, reason):
)

@api.model
def _fields_view_get(
self, view_id=None, view_type="form", toolbar=False, submenu=False
):
def get_view(self, view_id=None, view_type="form", **options):
"""Add filters for failed messages.
These filters will show up on any form or search views of any
model inheriting from ``mail.thread``.
"""
res = super()._fields_view_get(
view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu
)
res = super().get_view(view_id, view_type, **options)
if view_type != "search":
return res
doc = etree.XML(res["arch"])
Expand Down
183 changes: 183 additions & 0 deletions mail_tracking/static/src/components/discuss.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">

<t t-inherit="mail.DiscussSidebar" t-inherit-mode="extension">
<xpath
expr="//div[hasclass('o_DiscussSidebar_categoryMailbox')]"
position="inside"
>
<DiscussSidebarMailbox record="discussView.failedMessageView" />
</xpath>
</t>

<t t-inherit="mail.MessageList" t-inherit-mode="extension">
<t
t-elif="messageListView.threadViewOwner.thread === messaging.history.thread"
position="after"
>
<t
t-elif="messageListView.threadViewOwner.thread === messaging.failedmsg.thread"
>
<div class="o_MessageList_emptyTitle o-neutral-face-icon">
No failed messages
</div>
Failed messages will be appeared here.
</t>
</t>
</t>

<t t-inherit="mail.ThreadIcon" t-inherit-mode="extension">
<xpath
expr="//t[@t-elif='thread.mailbox === messaging.history']"
position="after"
>
<t t-elif="thread.mailbox === messaging.failedmsg">
<div class="o_ThreadIcon_mailboxModeration fa fa-fw fa-exclamation" />
</t>
</xpath>
</t>

<t t-name="mail.tracking.status" owl="1">
<t t-if="tracking['isCc']">
<span class="mail_tracking_cc">
<i class="fa fa-cc" />
</span>
</t>
<t t-elif="!tracking['isCc'] &amp;&amp; !tracking['partner_id']">
<span class="mail_anon_recipient">
<i class="fa fa-low-vision" />
</span>
</t>
<t t-elif="tracking['status'] === 'unknown'">
<span class="mail_tracking_unknown">
<i class="fa fa-ban" />
</span>
</t>
<t t-elif="tracking['status'] === 'waiting'">
<span class="mail_tracking_waiting mail_tracking_pointer">
<i class="fa fa-clock-o" />
</span>
</t>
<t t-elif="tracking['status'] === 'error'">
<span class="mail_tracking_error mail_tracking_pointer">
<i
t-if="tracking['error_type'] === 'no_recipient'"
class="fa fa-user-times"
/>
<i t-else="" class="fa fa-remove" />
</span>
</t>
<t t-elif="tracking['status'] === 'sent'">
<span class="mail_tracking_sent mail_tracking_pointer">
<i class="fa fa-check" />
</span>
</t>
<t t-elif="tracking['status'] === 'delivered'">
<span class="fa-stack mail_tracking_delivered mail_tracking_pointer">
<i class="fa fa-check fa-stack-1x" style="margin-left:1px" />
<i
class="fa fa-check fa-inverse fa-stack-1x"
style="margin-left:-2px;"
/>
<i class="fa fa-check fa-stack-1x" style="margin-left:-3px" />
</span>
</t>
<t t-elif="tracking['status'] === 'opened'">
<span class="fa-stack mail_tracking_opened mail_tracking_pointer">
<i class="fa fa-check fa-stack-1x" style="margin-left:1px" />
<i
class="fa fa-check fa-inverse fa-stack-1x"
style="margin-left:-2px;"
/>
<i class="fa fa-check fa-stack-1x" style="margin-left:-3px" />
</span>
</t>
</t>

<t t-inherit="mail.Message" t-inherit-mode="extension">
<xpath expr="//div[hasclass('o_Message_header')]" position="inside">
<t t-if="messageView.message.isFailed">
<span t-attf-class="o_thread_icons">
<a
href="#"
class="btn btn-link btn-success o_thread_icon text-muted btn-sm o_failed_message_reviewed o_activity_link"
t-on-click="_onMarkFailedMessageReviewed"
t-att-data-message-id="messageView.message.id"
>
<i class="fa fa-check" />
Set as Reviewed
</a>
<a
href="#"
class="btn btn-link btn-success o_thread_icon text-muted btn-sm o_failed_message_retry o_activity_link"
t-on-click="_onRetryFailedMessage"
t-att-data-message-id="messageView.message.id"
>
<i class="fa fa-retweet" />
Retry
</a>
</span>
</t>
</xpath>
</t>

<t
t-name="mail.MessageTracking"
t-inherit="mail.Message"
t-inherit-mode="extension"
>
<xpath expr="//div[hasclass('o_Message_header')]" position="after">
<t
t-if="messageView.message.hasPartnerTrackings() || messageView.message.hasEmailCc()"
>
<p class="o_mail_tracking">
<strong>To:</strong>
<t
t-foreach="messageView.message.getPartnerTrackings()"
t-as="tracking"
t-key="tracking_index"
>
<t t-if="!tracking_first">
-
</t>
<t t-if="tracking['partner_id']">
<a
t-attf-class="o_mail_action_tracking_partner #{tracking['isCc'] ? 'o_mail_cc' : ''}"
t-att-data-partner="tracking['partner_id']"
t-attf-href="#model=res.partner&amp;id={{tracking['partner_id']}}"
>
<t t-esc="tracking['recipient']" />
</a>
</t>
<t t-else="">
<span t-attf-class="#{tracking['isCc'] ? 'o_mail_cc' : ''}">
<t t-esc="tracking['recipient']" />
</span>
</t>
<t
t-if="tracking['status'] === 'error' &amp;&amp; tracking['error_type'] === 'no_recipient'"
t-set="title_status"
t-value="tracking['error_description']"
/>
<t
t-else=""
t-set="title_status"
t-value="tracking['status_human']"
/>
<span
class="mail_tracking o_mail_action_tracking_status"
t-att-data-tracking="tracking['tracking_id']"
t-att-title="title_status"
type="button"
t-on-click="_onTrackingStatusClick"
>
<t t-call="mail.tracking.status" />
</span>
</t>
</p>
</t>

</xpath>
</t>

</templates>
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,15 @@ export class MessageFailedBox extends Component {
}

/**
* @returns {Chatter}
* @returns {MessageFailedBoxView}
*/
get chatter() {
return this.messaging.models["mail.chatter"].get(this.props.chatterLocalId);
get messageFailedBoxView() {
return this.props.record;
}
}

Object.assign(MessageFailedBox, {
props: {
chatterLocalId: String,
},
props: {record: Object},
template: "mail_tracking.MessageFailedBox",
});

Expand Down
Loading

0 comments on commit dd63684

Please sign in to comment.