Browse Source

Merge pull request #189 from KolushovAlexandr/12.0-mail_sent-port

⬆️1️⃣2️⃣ mail_sent
pull/194/head
Ramil 6 years ago
committed by GitHub
parent
commit
5b7a01b9be
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      mail_sent/README.rst
  2. 6
      mail_sent/__manifest__.py
  3. 4
      mail_sent/static/description/index.html
  4. 91
      mail_sent/static/src/js/sent.js
  5. 11
      mail_sent/static/src/xml/menu.xml
  6. 14
      mail_sent/tests/test_js.py

8
mail_sent/README.rst

@ -20,7 +20,7 @@ Maintainers
----------- -----------
* `IT-Projects LLC <https://it-projects.info>`__ * `IT-Projects LLC <https://it-projects.info>`__
To get a guaranteed support you are kindly requested to purchase the module at `odoo apps store <https://apps.odoo.com/apps/modules/11.0/mail_sent/>`__.
To get a guaranteed support you are kindly requested to purchase the module at `odoo apps store <https://apps.odoo.com/apps/modules/12.0/mail_sent/>`__.
Thank you for understanding! Thank you for understanding!
@ -29,12 +29,12 @@ Maintainers
Further information Further information
=================== ===================
Demo: http://runbot.it-projects.info/demo/mail_addons/11.0
Demo: http://runbot.it-projects.info/demo/mail_addons/12.0
HTML Description: https://apps.odoo.com/apps/modules/11.0/mail_sent/
HTML Description: https://apps.odoo.com/apps/modules/12.0/mail_sent/
Usage instructions: `<doc/index.rst>`_ Usage instructions: `<doc/index.rst>`_
Changelog: `<doc/changelog.rst>`_ Changelog: `<doc/changelog.rst>`_
Tested on Odoo 11.0 ecbf7aa4714479229658d14cce28fa00376ed390
Tested on Odoo 12.0 c423e5fe047a66517a60b68874e18dc5c3697787

6
mail_sent/__manifest__.py

@ -3,7 +3,7 @@
"summary": """Quick way to find sent messages""", "summary": """Quick way to find sent messages""",
"category": "Discuss", "category": "Discuss",
"images": ['images/menu.png'], "images": ['images/menu.png'],
"version": "11.0.1.0.4",
"version": "12.0.1.0.4",
"author": "IT-Projects LLC, Ivan Yelizariev, Pavel Romanchenko", "author": "IT-Projects LLC, Ivan Yelizariev, Pavel Romanchenko",
"support": "apps@it-projects.info", "support": "apps@it-projects.info",
@ -13,9 +13,7 @@
'currency': 'EUR', 'currency': 'EUR',
"depends": [ "depends": [
"base",
"mail", "mail",
"mail_base"
], ],
"data": [ "data": [
@ -24,5 +22,5 @@
"qweb": [ "qweb": [
"static/src/xml/menu.xml", "static/src/xml/menu.xml",
], ],
'installable': False,
'installable': True,
} }

4
mail_sent/static/description/index.html

@ -61,7 +61,7 @@ This menu shows messages in threads (like in other menus), but shows only sent m
-o-transform: rotate(6deg); -o-transform: rotate(6deg);
-moz-transform: rotate(6deg); -moz-transform: rotate(6deg);
-ms-transform: rotate(6deg);"> -ms-transform: rotate(6deg);">
Tested on Odoo<br/>11.0 community
Tested on Odoo<br/>12.0 community
</div> </div>
<div style="margin-top: 15px; <div style="margin-top: 15px;
position: relative; position: relative;
@ -78,7 +78,7 @@ This menu shows messages in threads (like in other menus), but shows only sent m
-o-transform: rotate(-7deg); -o-transform: rotate(-7deg);
-moz-transform: rotate(-7deg); -moz-transform: rotate(-7deg);
-ms-transform: rotate(-7deg);"> -ms-transform: rotate(-7deg);">
Tested on Odoo<br/>11.0 enterprise
Tested on Odoo<br/>12.0 enterprise
</div> </div>
</div> </div>
</div> </div>

91
mail_sent/static/src/js/sent.js

@ -3,67 +3,48 @@ odoo.define('mail_sent.sent', function (require) {
var core = require('web.core'); var core = require('web.core');
var session = require('web.session'); var session = require('web.session');
var chat_manager = require('mail_base.base').chat_manager;
var _lt = core._lt;
var ChatAction = core.action_registry.get('mail.chat.instant_messaging');
ChatAction.include({
init: function (parent, action, options) {
this._super.apply(this, arguments);
var channel_name = 'channel_sent';
// Add channel Sent for show "Send message" button
this.channels_show_send_button.push(channel_name);
// Add channel Sent for enable "display_subject" option
this.channels_display_subject.push(channel_name);
var Manager = require('mail.Manager');
var Mailbox = require('mail.model.Mailbox');
var _t = core._t;
Manager.include({
_updateMailboxesFromServer: function (data) {
var self = this;
this._super(data);
if (!_.find(this.getThreads(), function(th){
return th.getID() === 'mailbox_channel_sent';
})) {
this._addMailbox({
id: 'channel_sent',
name: _t("Sent Messages"),
mailboxCounter: data.needaction_inbox_counter || 0,
});
}
}, },
update_message_on_current_channel: function (current_channel_id, message) {
var result = this._super.apply(this, arguments);
var sent = current_channel_id === "channel_sent" && !message.is_sent;
return sent || result;
}
_makeMessage: function (data) {
var message = this._super(data);
message._addThread('mailbox_channel_sent');
return message;
},
}); });
// Inherit class and override methods
var chat_manager_super = _.clone(chat_manager);
chat_manager.get_properties = function (msg) {
var properties = chat_manager_super.get_properties.apply(this, arguments);
properties.is_sent = this.property_descr("channel_sent", msg, this);
return properties;
};
chat_manager.set_channel_flags = function (data, msg) {
chat_manager_super.set_channel_flags.apply(this, arguments);
if (data.sent && data.author_id[0] === session.partner_id) {
msg.is_sent = true;
Mailbox.include({
_getThreadDomain: function () {
if (this._id === 'mailbox_channel_sent') {
return [
['sent', '=', true],
['author_id.user_ids', 'in', [session.uid]]
];
} }
return msg;
};
chat_manager.get_channel_array = function (msg) {
var arr = chat_manager_super.get_channel_array.apply(this, arguments);
return arr.concat('channel_sent');
};
chat_manager.get_domain = function (channel) {
return (channel.id === "channel_sent")
? [['sent', '=', true],['author_id.user_ids', 'in', [session.uid]]]
: chat_manager_super.get_domain.apply(this, arguments);
};
chat_manager.is_ready.then(function () {
// Add sent channel
chat_manager.add_channel({
id: "channel_sent",
name: _lt("Sent"),
type: "static"
});
return $.when();
return this._super();
},
}); });
return chat_manager;
return {
'Manager': Manager,
'Mailbox': Mailbox,
};
}); });

11
mail_sent/static/src/xml/menu.xml

@ -1,17 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<template> <template>
<!--Inherit Sidebar and add Sent menu item after Starred --> <!--Inherit Sidebar and add Sent menu item after Starred -->
<t t-extend="mail.chat.Sidebar">
<t t-jquery="div[data-channel-id=channel_inbox]" t-operation="after">
<div t-attf-class="o_mail_chat_title_main o_mail_chat_channel_item #{(active_channel_id == 'channel_sent') ? 'o_active': ''}" data-channel-id="channel_sent">
<t t-extend="mail.discuss.Sidebar">
<t t-jquery="div[data-thread-id=mailbox_starred]" t-operation="after">
<div t-attf-class="o_mail_discuss_title_main o_mail_mailbox_title_sent o_mail_discuss_item #{(activeThreadID == 'channel_sent') ? 'o_active': ''}"
data-thread-id="mailbox_channel_sent">
<span class="o_channel_name mail_sent"> <i class="fa fa-send-o"/> Sent </span> <span class="o_channel_name mail_sent"> <i class="fa fa-send-o"/> Sent </span>
</div> </div>
</t> </t>
</t> </t>
<!--Add message about empty sent page--> <!--Add message about empty sent page-->
<t t-extend="mail.EmptyChannel">
<t t-extend="mail.widget.Thread.Empty">
<t t-jquery="t:last-child" t-operation="after"> <t t-jquery="t:last-child" t-operation="after">
<t t-if="options.channel_id==='channel_sent'">
<t t-if="thread.getID() === 'mailbox_channel_sent'">
<div class="o_thread_title">No sent messages</div> <div class="o_thread_title">No sent messages</div>
<div>You can send messages and then these messages will appear here.</div> <div>You can send messages and then these messages will appear here.</div>
</t> </t>

14
mail_sent/tests/test_js.py

@ -1,17 +1,25 @@
import odoo.tests import odoo.tests
from werkzeug import url_encode
@odoo.tests.common.at_install(False)
@odoo.tests.common.at_install(True)
@odoo.tests.common.post_install(True) @odoo.tests.common.post_install(True)
class TestUi(odoo.tests.HttpCase): class TestUi(odoo.tests.HttpCase):
def test_01_mail_sent(self): def test_01_mail_sent(self):
# wait till page loaded and then click and wait again # wait till page loaded and then click and wait again
# needed because tests are run before the module is marked as
# installed. In js web will only load qweb coming from modules
# that are returned by the backend in module_boot. Without
# this you end up with js, css but no qweb.
self.env['ir.module.module'].search([('name', '=', 'mail_sent')], limit=1).state = 'installed'
code = """ code = """
setTimeout(function () { setTimeout(function () {
$(".mail_sent").click(); $(".mail_sent").click();
setTimeout(function () {console.log('ok');}, 3000); setTimeout(function () {console.log('ok');}, 3000);
}, 1000); }, 1000);
""" """
link = '/web#action=%s' % self.ref('mail.mail_channel_action_client_chat')
self.phantom_js(link, code, "odoo.__DEBUG__.services['mail_sent.sent'].is_ready", login="demo")
link = '/web#%s' % url_encode({'action': 'mail.action_discuss'})
self.phantom_js(link, code, "odoo.__DEBUG__.services['web_tour.tour'].tours.mail_tour.ready", login="demo")
Loading…
Cancel
Save