David
7 years ago
committed by
Jairo Llopis
24 changed files with 122 additions and 168 deletions
-
11mail_tracking/README.rst
-
3mail_tracking/__init__.py
-
8mail_tracking/__manifest__.py
-
3mail_tracking/controllers/__init__.py
-
9mail_tracking/controllers/main.py
-
2mail_tracking/data/tracking_data.xml
-
3mail_tracking/hooks.py
-
3mail_tracking/models/__init__.py
-
18mail_tracking/models/ir_mail_server.py
-
3mail_tracking/models/mail_mail.py
-
3mail_tracking/models/mail_message.py
-
24mail_tracking/models/mail_tracking_email.py
-
3mail_tracking/models/mail_tracking_event.py
-
3mail_tracking/models/res_partner.py
-
2mail_tracking/security/mail_tracking_email_security.xml
-
2mail_tracking/static/src/css/mail_tracking.css
-
163mail_tracking/static/src/js/mail_tracking.js
-
4mail_tracking/static/src/xml/mail_tracking.xml
-
2mail_tracking/tests/__init__.py
-
13mail_tracking/tests/test_mail_tracking.py
-
2mail_tracking/views/assets.xml
-
2mail_tracking/views/mail_tracking_email_view.xml
-
2mail_tracking/views/mail_tracking_event_view.xml
-
2mail_tracking/views/res_partner_view.xml
@ -1,7 +1,4 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2016 Antonio Espinosa - <antonio.espinosa@tecnativa.com> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
# flake8: noqa |
|||
|
|||
from . import models |
|||
from . import controllers |
|||
|
@ -1,6 +1,3 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2016 Antonio Espinosa - <antonio.espinosa@tecnativa.com> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
# flake8: noqa |
|||
|
|||
from . import main |
@ -1,98 +1,83 @@ |
|||
/* © 2016 Antonio Espinosa - <antonio.espinosa@tecnativa.com> |
|||
/* Copyright 2016 Antonio Espinosa - <antonio.espinosa@tecnativa.com> |
|||
Copyright 2018 David Vidal - <david.vidal@tecnativa.com> |
|||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). */
|
|||
|
|||
odoo.define('mail_tracking.partner_tracking', function(require){ |
|||
"use strict"; |
|||
"use strict"; |
|||
|
|||
var core = require('web.core'); |
|||
var session = require('web.session'); |
|||
var Model = require('web.Model'); |
|||
var ActionManager = require('web.ActionManager'); |
|||
var ChatThread = require('mail.ChatThread'); |
|||
var core = require('web.core'); |
|||
var session = require('web.session'); |
|||
var data = require('web.data'); |
|||
var ActionManager = require('web.ActionManager'); |
|||
var chat_manager = require('mail.chat_manager'); |
|||
var ChatThread = require('mail.ChatThread'); |
|||
var Chatter = require('mail.Chatter'); |
|||
|
|||
var _t = core._t; |
|||
var MessageModel = new Model('mail.message', session.context); |
|||
var _t = core._t; |
|||
|
|||
|
|||
ChatThread.include({ |
|||
_preprocess_message: function (message) { |
|||
var msg = this._super.apply(this, arguments); |
|||
msg.partner_trackings = msg.partner_trackings || []; |
|||
// chat_manager is a simple dictionary, not an OdooClass
|
|||
chat_manager._make_message_super = chat_manager.make_message; |
|||
chat_manager.make_message = function(data) { |
|||
var msg = this._make_message_super(data); |
|||
msg.partner_trackings = data.partner_trackings || []; |
|||
return msg; |
|||
}, |
|||
on_tracking_partner_click: function (event) { |
|||
var partner_id = this.$el.find(event.currentTarget).data('partner'); |
|||
var state = { |
|||
'model': 'res.partner', |
|||
'id': partner_id, |
|||
'title': _t("Tracking partner"), |
|||
}; |
|||
event.preventDefault(); |
|||
this.action_manager.do_push_state(state); |
|||
var action = { |
|||
type:'ir.actions.act_window', |
|||
view_type: 'form', |
|||
view_mode: 'form', |
|||
res_model: 'res.partner', |
|||
views: [[false, 'form']], |
|||
target: 'current', |
|||
res_id: partner_id, |
|||
}; |
|||
this.do_action(action); |
|||
}, |
|||
on_tracking_status_click: function (event) { |
|||
var tracking_email_id = $(event.currentTarget).data('tracking'); |
|||
var state = { |
|||
'model': 'mail.tracking.email', |
|||
'id': tracking_email_id, |
|||
'title': _t("Message tracking"), |
|||
}; |
|||
event.preventDefault(); |
|||
this.action_manager.do_push_state(state); |
|||
var action = { |
|||
type:'ir.actions.act_window', |
|||
view_type: 'form', |
|||
view_mode: 'form', |
|||
res_model: 'mail.tracking.email', |
|||
views: [[false, 'form']], |
|||
target: 'new', |
|||
res_id: tracking_email_id, |
|||
}; |
|||
this.do_action(action); |
|||
}, |
|||
bind_events: function () { |
|||
this.$el.on('click', '.o_mail_action_tracking_partner', |
|||
this.on_tracking_partner_click); |
|||
this.$el.on('click', '.o_mail_action_tracking_status', |
|||
this.on_tracking_status_click); |
|||
}, |
|||
init: function (parent, options) { |
|||
this._super.apply(this, arguments); |
|||
this.action_manager = this.findAncestor(function(ancestor){ |
|||
return ancestor instanceof ActionManager; |
|||
}); |
|||
}, |
|||
start: function () { |
|||
this._super(); |
|||
this.bind_events(); |
|||
}, |
|||
render: function(messages, options) { |
|||
var self = this, render_super = this._super, |
|||
msgs = {}, |
|||
msg_ids = []; |
|||
// Update trackings (async) each time we re-render thread
|
|||
_.each(messages, function (message) { |
|||
msgs[message.id] = message; |
|||
msg_ids.push(message.id); |
|||
}); |
|||
MessageModel.call('tracking_status', [msg_ids]).then(function (trackings) { |
|||
_.each(trackings, function (tracking, id) { |
|||
msgs[id].partner_trackings = tracking; |
|||
}); |
|||
render_super.apply(self, [messages, options]); |
|||
}); |
|||
}, |
|||
}; |
|||
|
|||
ChatThread.include({ |
|||
events: _.extend(ChatThread.prototype.events, { |
|||
'click .o_mail_action_tracking_partner': 'on_tracking_partner_click', |
|||
'click .o_mail_action_tracking_status': 'on_tracking_status_click', |
|||
}), |
|||
_preprocess_message: function (message) { |
|||
var msg = this._super.apply(this, arguments); |
|||
msg.partner_trackings = msg.partner_trackings || []; |
|||
return msg; |
|||
}, |
|||
on_tracking_partner_click: function (event) { |
|||
var partner_id = this.$el.find(event.currentTarget).data('partner'); |
|||
var state = { |
|||
'model': 'res.partner', |
|||
'id': partner_id, |
|||
'title': _t("Tracking partner"), |
|||
}; |
|||
event.preventDefault(); |
|||
this.action_manager.do_push_state(state); |
|||
var action = { |
|||
type:'ir.actions.act_window', |
|||
view_type: 'form', |
|||
view_mode: 'form', |
|||
res_model: 'res.partner', |
|||
views: [[false, 'form']], |
|||
target: 'current', |
|||
res_id: partner_id, |
|||
}; |
|||
this.do_action(action); |
|||
}, |
|||
on_tracking_status_click: function (event) { |
|||
var tracking_email_id = $(event.currentTarget).data('tracking'); |
|||
var state = { |
|||
'model': 'mail.tracking.email', |
|||
'id': tracking_email_id, |
|||
'title': _t("Message tracking"), |
|||
}; |
|||
event.preventDefault(); |
|||
this.action_manager.do_push_state(state); |
|||
var action = { |
|||
type:'ir.actions.act_window', |
|||
view_type: 'form', |
|||
view_mode: 'form', |
|||
res_model: 'mail.tracking.email', |
|||
views: [[false, 'form']], |
|||
target: 'new', |
|||
res_id: tracking_email_id, |
|||
}; |
|||
this.do_action(action); |
|||
}, |
|||
init: function (parent, options) { |
|||
this._super.apply(this, arguments); |
|||
this.action_manager = this.findAncestor(function(ancestor){ |
|||
return ancestor instanceof ActionManager; |
|||
}); |
|||
}, |
|||
}); |
|||
}); |
|||
|
|||
}); // odoo.define
|
@ -1,5 +1,5 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2016 Antonio Espinosa - <antonio.espinosa@tecnativa.com> |
|||
# Copyright 2016 Antonio Espinosa - <antonio.espinosa@tecnativa.com> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
# flake8: noqa |
|||
|
|||
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue