-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
120 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "Mail Chatter Statistics", | ||
"version": "16.0.1.0.0", | ||
"author": "Avanzosc", | ||
"summary": "Add email tracking functionality to Odoo chatter.", | ||
"website": "https://github.com/avanzosc/odoo-addons", | ||
"license": "LGPL-3", | ||
"depends": ["mail", "mass_mailing"], | ||
"data": [ | ||
"views/mail_mail_views.xml", | ||
"views/mailing_trace_views.xml", | ||
], | ||
"installable": True, | ||
"application": False, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import mail_mail | ||
from . import mailing_trace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from odoo import models | ||
|
||
|
||
class MailMail(models.Model): | ||
_inherit = "mail.mail" | ||
|
||
def send(self, auto_commit=False, raise_exception=False): | ||
res = super().send(auto_commit=auto_commit, raise_exception=raise_exception) | ||
|
||
for mail in self: | ||
trace = self.env["mailing.trace"].create( | ||
{ | ||
"mail_id": mail.id, | ||
"email": mail.email_to, | ||
"status": "sent", | ||
"message_id": mail.message_id, | ||
} | ||
) | ||
mail.body_html = self._add_tracking(mail.body_html, trace.id) | ||
trace.write({"status": "tracking_added"}) | ||
|
||
return res | ||
|
||
def _add_tracking(self, body_html, trace_id): | ||
""" | ||
Agregar píxel de seguimiento y reemplazar enlaces para el seguimiento de clics | ||
""" | ||
tracking_pixel = f'<img src="/mail/track/open/{trace_id}"\ | ||
width="1" height="1" style="display:none"/>' | ||
body_html = body_html.replace("</body>", f"{tracking_pixel}</body>") | ||
|
||
return body_html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from odoo import fields, models | ||
|
||
|
||
class MailingTrace(models.Model): | ||
_name = "mailing.trace" | ||
_description = "Email Tracking for Chatter" | ||
|
||
mail_id = fields.Many2one("mail.mail", string="Mail") | ||
email = fields.Char(string="Email") | ||
message_id = fields.Char(string="Message ID") | ||
status = fields.Selection( | ||
[ | ||
("sent", "Sent"), | ||
("tracking_added", "Tracking Added"), | ||
("opened", "Opened"), | ||
("clicked", "Clicked"), | ||
("bounced", "Bounced"), | ||
], | ||
string="Status", | ||
) | ||
open_count = fields.Integer(string="Open Count", default=0) | ||
click_count = fields.Integer(string="Click Count", default=0) | ||
|
||
def track_open(self): | ||
""" | ||
Método que incrementa el contador de aperturas. | ||
""" | ||
self.open_count += 1 | ||
self.status = "opened" | ||
|
||
def track_click(self): | ||
""" | ||
Método que incrementa el contador de clics. | ||
""" | ||
self.click_count += 1 | ||
self.status = "clicked" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> <record id="view_mail_form_inherit_chatter_stats" model="ir.ui.view"> | ||
<field name="name">mail.mail.form.view.stats</field> | ||
<field name="model">mail.mail</field> | ||
<field name="inherit_id" ref="mail.view_mail_mail_form" /> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//header" position="inside"> | ||
<button | ||
name="%(action_show_tracking)d" | ||
string="Show Email Tracking" | ||
type="action" | ||
class="btn-primary" | ||
/> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
<record id="action_show_tracking" model="ir.actions.act_window"> | ||
<field name="name">Email Tracking</field> | ||
<field name="res_model">mailing.trace</field> | ||
<field name="view_mode">tree,form</field> | ||
<field name="target">new</field> | ||
</record> | ||
</odoo> |
1 change: 1 addition & 0 deletions
1
setup/mail_chatter_statistics/odoo/addons/mail_chatter_statistics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../mail_chatter_statistics |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |