Browse Source

[11.0][PORT] port mail_base, mail_all, mail_archives, mail_sent to v11 (#127)

* [PORT] Ported_mail archives, mail_to, mail_base to Odoo 11.0

* [FIX] mail_base get_domain method fix; mail_archives add channel fix

* [PORT] mail all to 11.0

* [PORT] mail_sent to 11.0

* [FIX] mail_archives domain fix

* [FIX] mail_base additional condition fix

* [FIX] channel preview fix
pull/142/head
ArtyomLosev 7 years ago
committed by ILMIR
parent
commit
7de69b098a
  1. 35
      mail_all/README.rst
  2. 2
      mail_all/__init__.py
  3. 10
      mail_all/__openerp__.py
  4. 3
      mail_all/doc/changelog.rst
  5. 10
      mail_all/doc/index.rst
  6. 1
      mail_all/models/__init__.py
  7. 3
      mail_all/static/src/css/mail_all.css
  8. 62
      mail_all/static/src/js/mail_all.js
  9. 2
      mail_all/static/src/xml/menu.xml
  10. 1
      mail_all/views/templates.xml
  11. 40
      mail_archives/README.rst
  12. 2
      mail_archives/__openerp__.py
  13. 4
      mail_archives/doc/changelog.rst
  14. 20
      mail_archives/doc/index.rst
  15. 3
      mail_archives/static/src/css/archives.css
  16. 97
      mail_archives/static/src/js/archives.js
  17. 2
      mail_archives/static/src/xml/menu.xml
  18. 1
      mail_archives/views/templates.xml
  19. 30
      mail_base/README.rst
  20. 20
      mail_base/doc/index.rst
  21. 2255
      mail_base/static/lib/base.js
  22. 3
      mail_base/tests/__init__.py
  23. 17
      mail_base/tests/test_default.py
  24. 31
      mail_reply/README.rst
  25. 3
      mail_reply/doc/changelog.rst
  26. 10
      mail_reply/doc/index.rst
  27. 25
      mail_reply/static/src/js/mail_reply.js
  28. 4
      mail_reply/static/src/xml/reply_button.xml
  29. 3
      mail_reply/tests/__init__.py
  30. 40
      mail_reply/tests/test_default.py
  31. 42
      mail_sent/README.rst
  32. 2
      mail_sent/__openerp__.py
  33. 19
      mail_sent/doc/index.rst
  34. 2
      mail_sent/models.py
  35. 3
      mail_sent/static/src/css/sent.css
  36. 80
      mail_sent/static/src/js/sent.js
  37. 2
      mail_sent/static/src/xml/menu.xml
  38. 1
      mail_sent/views/templates.xml
  39. 13
      mail_to/README.rst
  40. 2
      mail_to/__openerp__.py
  41. 47
      mail_to/static/src/js/mail_to.js
  42. 1
      mail_to/tests/__init__.py
  43. 17
      mail_to/tests/test_default.py

35
mail_all/README.rst

@ -2,15 +2,38 @@
Show all messages
===================
Adds ``Discuss / All`` menu, that shows all messages accesable by current user
Adds ``Discuss / All`` menu, that shows all messages accesable by current user.
Credits
=======
Contributors
------------
* Pavel Romanchenko <apps@it-projects.info>
Sponsors
--------
* `IT-Projects LLC <https://it-projects.info>`__
Maintainers
-----------
* `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_all/>`__.
Thank you for understanding!
`IT-Projects Team <https://www.it-projects.info/team>`__
Further information
-------------------
===================
Demo: http://runbot.it-projects.info/demo/mail_addons/11.0
HTML Description: https://apps.odoo.com/apps/modules/9.0/mail_all/
HTML Description: https://apps.odoo.com/apps/modules/11.0/mail_all/
Usage instructions: `<doc/index.rst>`__
Usage instructions: `<doc/index.rst>`_
Changelog: `<doc/changelog.rst>`__
Changelog: `<doc/changelog.rst>`_
Tested on Odoo 9.0 d3dd4161ad0598ebaa659fbd083457c77aa9448d
Tested on Odoo 11.0 ecbf7aa4714479229658d14cce28fa00376ed390

2
mail_all/__init__.py

@ -1,3 +1 @@
# -*- coding: utf-8 -*-
from . import models

10
mail_all/__openerp__.py

@ -3,8 +3,10 @@
"name": "Show all messages",
"summary": """Checkout all messages where you have access""",
"category": "Discuss",
# "live_test_url": "",
"images": ['images/1.jpg'],
"version": "1.0.0",
"application": False,
"author": "IT-Projects LLC, Pavel Romanchenko",
"support": "apps@it-projects.info",
@ -24,6 +26,12 @@
"static/src/xml/menu.xml",
],
"demo": [],
'installable': False,
"post_load": None,
"pre_init_hook": None,
"post_init_hook": None,
"uninstall_hook": None,
'installable': True,
"auto_install": False,
}

3
mail_all/doc/changelog.rst

@ -1,6 +1,3 @@
Updates
=======
`1.0.0`
-------

10
mail_all/doc/index.rst

@ -2,6 +2,16 @@
Show all messages
===================
Installation
============
* `Install <https://odoo-development.readthedocs.io/en/latest/odoo/usage/install-module.html>`__ this module in a usual way
Configuration
=============
This module does not require special configuration.
Usage
=====

1
mail_all/models/__init__.py

@ -1 +0,0 @@
# -*- coding: utf-8 -*-

3
mail_all/static/src/css/mail_all.css

@ -0,0 +1,3 @@
.o_channel_name.mail_all i {
margin-right: 4px;
}

62
mail_all/static/src/js/mail_all.js

@ -1,20 +1,10 @@
odoo.define('mail_all.all', function (require) {
"use strict";
var base_obj = require('mail_base.base');
//-------------------------------------------------------------------------------
var bus = require('bus.bus').bus;
var config = require('web.config');
var chat_manager = require('mail_base.base').chat_manager;
var core = require('web.core');
var data = require('web.data');
var Model = require('web.Model');
var session = require('web.session');
var time = require('web.time');
var web_client = require('web.web_client');
var _lt = core._lt;
//-------------------------------------------------------------------------------
var ChatAction = core.action_registry.get('mail.chat.instant_messaging');
ChatAction.include({
@ -25,41 +15,43 @@ ChatAction.include({
}
});
// Inherit class and override methods
base_obj.MailTools.include({
get_properties: function(msg){
var properties = this._super.apply(this, arguments);
properties.is_all = this.property_descr("channel_all", msg, this);
return properties;
},
// override methods
var chat_manager_super = _.clone(chat_manager);
set_channel_flags: function(data, msg){
this._super.apply(this, arguments);
msg.is_all = data.author_id != 'ODOOBOT';
return msg;
},
chat_manager.get_properties = function (msg) {
var properties = chat_manager_super.get_properties.apply(this, arguments);
properties.is_all = this.property_descr("channel_all", msg, this);
return properties;
};
get_channel_array: function(msg){
var arr = this._super.apply(this, arguments);
return arr.concat('channel_all');
},
chat_manager.set_channel_flags = function (data, msg) {
chat_manager_super.set_channel_flags.apply(this, arguments);
msg.is_all = data.author_id !== 'ODOOBOT';
return msg;
};
get_domain: function(channel){
return (channel.id === "channel_all") ? [] : this._super.apply(this, arguments);
}
});
chat_manager.get_channel_array = function (msg) {
var arr = chat_manager_super.get_channel_array.apply(this, arguments);
return arr.concat('channel_all');
};
base_obj.chat_manager.is_ready.then(function(){
chat_manager.get_domain = function (channel) {
return (channel.id === "channel_all")
? []
: chat_manager_super.get_domain.apply(this, arguments);
};
chat_manager.is_ready.then(function () {
// Add all channel
base_obj.chat_manager.mail_tools.add_channel({
chat_manager.add_channel({
id: "channel_all",
name: _lt("All messages"),
type: "static"
});
return $.when();
});
return base_obj.chat_manager;
return chat_manager;
});

2
mail_all/static/src/xml/menu.xml

@ -3,7 +3,7 @@
<!--Inherit Sidebar and add All messages menu item after Starred -->
<t t-extend="mail.chat.Sidebar">
<t t-jquery="div[data-channel-id=channel_starred]" t-operation="after">
<div t-attf-class="o_mail_chat_channel_item #{(active_channel_id == 'channel_all') ? 'o_active': ''}" data-channel-id="channel_all">
<div t-attf-class="o_mail_chat_title_main o_mail_chat_channel_item #{(active_channel_id == 'channel_all') ? 'o_active': ''}" data-channel-id="channel_all">
<span class="o_channel_name mail_all"> <i class="fa fa-database"/> All messages </span>
</div>
</t>

1
mail_all/views/templates.xml

@ -5,6 +5,7 @@
name="mail_all_assets_backend"
inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<link rel="stylesheet" href="/mail_all/static/src/css/mail_all.css"/>
<script src="/mail_all/static/src/js/mail_all.js" type="text/javascript"></script>
</xpath>
</template>

40
mail_archives/README.rst

@ -1,15 +1,39 @@
Mail Archives
=============
===============
Mail Archives
===============
Adds Archive menu, which shows sent/received messages
Usage
-----
Click Discuss/Archive menu -- sent/received messages are displayed
Credits
=======
Contributors
------------
* Pavel Romanchenko <apps@it-projects.info>
Sponsors
--------
* `IT-Projects LLC <https://it-projects.info>`__
Maintainers
-----------
* `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_archives/>`__.
Thank you for understanding!
`IT-Projects Team <https://www.it-projects.info/team>`__
Further information
-------------------
===================
Demo: http://runbot.it-projects.info/demo/mail_addons/11.0
HTML Description: https://apps.odoo.com/apps/modules/11.0/mail_archives/
Usage instructions: `<doc/index.rst>`_
HTML Description: https://apps.odoo.com/apps/modules/9.0/mail_archives/
Changelog: `<doc/changelog.rst>`_
Tested on Odoo 9.0 b9f206953e3f877adf18643f154d1262842564ee
Tested on Odoo 11.0 ecbf7aa4714479229658d14cce28fa00376ed390

2
mail_archives/__openerp__.py

@ -23,5 +23,5 @@
"qweb": [
"static/src/xml/menu.xml",
],
'installable': False,
'installable': True,
}

4
mail_archives/doc/changelog.rst

@ -0,0 +1,4 @@
`1.0.0`
-------
- Init version

20
mail_archives/doc/index.rst

@ -0,0 +1,20 @@
==============
Mail Archives
==============
Installation
============
* `Install <https://odoo-development.readthedocs.io/en/latest/odoo/usage/install-module.html>`__ this module in a usual way
Configuration
=============
This module does not require special configuration.
Usage
=====
* Open ``Discuss``.
* Click ``Archive``.
* Sent/received messages are displayed.

3
mail_archives/static/src/css/archives.css

@ -0,0 +1,3 @@
.o_channel_name.mail_archives i {
margin-right: 4px;
}

97
mail_archives/static/src/js/archives.js

@ -1,31 +1,23 @@
odoo.define('mail_archives.archives', function (require) {
"use strict";
var base_obj = require('mail_base.base');
//-------------------------------------------------------------------------------
var bus = require('bus.bus').bus;
var config = require('web.config');
var core = require('web.core');
var data = require('web.data');
var Model = require('web.Model');
var session = require('web.session');
var time = require('web.time');
var web_client = require('web.web_client');
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) {
init: function (parent, action, options) {
this._super.apply(this, arguments);
var channel_name = 'channel_archive';
// Add channel Archive for enable "display_subject" option
this.channels_display_subject.push(channel_name);
},
update_message_on_current_channel: function(current_channel_id, message){
update_message_on_current_channel: function (current_channel_id, message){
var result = this._super.apply(this, arguments);
var archive = current_channel_id === "channel_archive" && !message.is_archive;
return archive || result;
@ -33,53 +25,52 @@ ChatAction.include({
});
// Inherit class and override methods
base_obj.MailTools.include({
get_properties: function(msg){
var properties = this._super.apply(this, arguments);
properties.is_archive = this.property_descr("channel_archive", msg, this);
return properties;
},
set_channel_flags: function(data, msg){
this._super.apply(this, arguments);
// Get recipients ids
var recipients_ids = [];
for (var i = 0; i < (data.partner_ids || []).length; i++){
recipients_ids.push(data.partner_ids[i][0]);
}
// If author or recipient
if (data.author_id[0] === session.partner_id || recipients_ids.indexOf(session.partner_id) != -1) {
msg.is_archive = true;
}
return msg;
},
var chat_manager_super = _.clone(chat_manager);
get_channel_array: function(msg){
var arr = this._super.apply(this, arguments);
return arr.concat('channel_archive');
},
chat_manager.get_properties = function (msg) {
var properties = chat_manager_super.get_properties.apply(this, arguments);
properties.is_archive = this.property_descr("channel_archive", msg, this);
return properties;
};
get_domain: function(channel){
return (channel.id === "channel_archive") ? [
'|', ['partner_ids', 'in', [openerp.session.partner_id]],
['author_id.user_ids', 'in', [openerp.session.uid]]
] : this._super.apply(this, arguments);
chat_manager.set_channel_flags = function (data, msg) {
chat_manager_super.set_channel_flags.apply(this, arguments);
// Get recipients ids
var recipients_ids = [];
for (var i = 0; i < (data.partner_ids || []).length; i++){
recipients_ids.push(data.partner_ids[i][0]);
}
});
base_obj.chat_manager.is_ready.then(function(){
// Add archive channel
base_obj.chat_manager.mail_tools.add_channel({
id: "channel_archive",
name: _lt("Archive"),
type: "static"
});
// If author or recipient
if (data.author_id[0] === session.partner_id || recipients_ids.indexOf(session.partner_id) !== -1) {
msg.is_archive = true;
}
return msg;
};
chat_manager.get_channel_array = function (msg) {
var arr = chat_manager_super.get_channel_array.apply(this, arguments);
return arr.concat('channel_archive');
};
return $.when();
chat_manager.get_domain = function (channel) {
return (channel.id === "channel_archive")
? ['|', ['partner_ids', 'in', [session.partner_id]],
['author_id', 'in', [session.partner_id]]]
: chat_manager_super.get_domain.apply(this, arguments);
};
chat_manager.is_ready.then(function () {
chat_manager.add_channel({
id: "channel_archive",
name: _lt("Archive"),
type: "static"
});
});
return base_obj.chat_manager;
return chat_manager;
});

2
mail_archives/static/src/xml/menu.xml

@ -3,7 +3,7 @@
<!--Inherit Sidebar and add Archive menu item after Starred -->
<t t-extend="mail.chat.Sidebar">
<t t-jquery="div[data-channel-id=channel_starred]" t-operation="after">
<div t-attf-class="o_mail_chat_channel_item #{(active_channel_id == 'channel_archive') ? 'o_active': ''}" data-channel-id="channel_archive">
<div t-attf-class="o_mail_chat_channel_item o_mail_chat_title_main #{(active_channel_id == 'channel_archive') ? 'o_active': ''}" data-channel-id="channel_archive">
<span class="o_channel_name mail_archives"> <i class="fa fa-archive"/> Archive </span>
</div>
</t>

1
mail_archives/views/templates.xml

@ -5,6 +5,7 @@
name="res_partner_mails_count_assets_backend"
inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<link rel="stylesheet" href="/mail_archives/static/src/css/archives.css"/>
<script src="/mail_archives/static/src/js/archives.js" type="text/javascript"></script>
</xpath>
</template>

30
mail_base/README.rst

@ -1,5 +1,6 @@
Mail Base
=========
===========
Mail Base
===========
* makes built-in mail js features extendable.
* handles ``search_default_*`` parameters in context.
@ -10,19 +11,38 @@ One can say, that the module do this todo from `addons/mail/static/src/js/chat_m
// to do: move this to mail.utils
Note. Due to odoo restrictions, module makes mail initialization again. That is browser loads emoji and other chat data twice. This is the only way to make Mail feature extendable.
Credits
=======
Note. Due to odoo restrictions, module makes mail initialization again. That is browser loads emoji and other chat data twice. This is the only way to make Mail feature extendable.
Contributors
------------
* Pavel Romanchenko <apps@it-projects.info>
Sponsors
--------
* `IT-Projects LLC <https://it-projects.info>`__
Maintainers
-----------
* `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_base/>`__.
Thank you for understanding!
`IT-Projects Team <https://www.it-projects.info/team>`__
Further information
===================
Demo: http://runbot.it-projects.info/demo/mail-addons/11.0
.. HTML Description: https://apps.odoo.com/apps/modules/11.0/mail_base/
HTML Description: https://apps.odoo.com/apps/modules/11.0/mail_base/
Usage instructions: `<doc/index.rst>`_
Changelog: `<doc/changelog.rst>`_
Tested on Odoo 11.0 1be57f2825af4f3ade20a658c6f97f6cf93cc866
Tested on Odoo 11.0 ecbf7aa4714479229658d14cce28fa00376ed390

20
mail_base/doc/index.rst

@ -1,4 +1,18 @@
Mail Base
=========
=========================
Mail Base
=========================
To use this module you need either install module that depends on it or create new module.
Installation
============
* `Install <https://odoo-development.readthedocs.io/en/latest/odoo/usage/install-module.html>`__ this module in a usual way
Configuration
=============
This module does not require special configuration.
Usage
=====
* To use this module you need either install module that depends on it or create new module.

2255
mail_base/static/lib/base.js
File diff suppressed because it is too large
View File

3
mail_base/tests/__init__.py

@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import test_default

17
mail_base/tests/test_default.py

@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
import odoo.tests
@odoo.tests.common.at_install(False)
@odoo.tests.common.post_install(True)
class TestUi(odoo.tests.HttpCase):
def test_01_mail_base(self):
# wait till page loaded
code = """
setTimeout(function () {
console.log('ok');
}, 1000);
"""
link = '/web#action=%s' % self.ref('mail.mail_channel_action_client_chat')
self.phantom_js(link, code, "odoo.__DEBUG__.services['mail_base.base']", login="admin")

31
mail_reply/README.rst

@ -4,13 +4,36 @@
The module allows to reply to any message. Out-of-box odoo shows reply button for messages attached to some record.
Credits
=======
Contributors
------------
* Pavel Romanchenko <apps@it-projects.info>
Sponsors
--------
* `IT-Projects LLC <https://it-projects.info>`__
Maintainers
-----------
* `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_reply/>`__.
Thank you for understanding!
`IT-Projects Team <https://www.it-projects.info/team>`__
Further information
===================
HTML Description: https://apps.odoo.com/apps/modules/9.0/mail_reply/
Demo: http://runbot.it-projects.info/demo/mail_addons/11.0
HTML Description: https://apps.odoo.com/apps/modules/11.0/mail_reply/
Usage instructions: `<doc/index.rst>`__
Usage instructions: `<doc/index.rst>`_
Changelog: `<doc/changelog.rst>`__
Changelog: `<doc/changelog.rst>`_
Tested on Odoo 9.0 d3dd4161ad0598ebaa659fbd083457c77aa9448d
Tested on Odoo 11.0 ecbf7aa4714479229658d14cce28fa00376ed390

3
mail_reply/doc/changelog.rst

@ -1,6 +1,3 @@
Updates
=======
`1.0.0`
-------

10
mail_reply/doc/index.rst

@ -2,6 +2,16 @@
Show reply button
===================
Installation
============
* `Install <https://odoo-development.readthedocs.io/en/latest/odoo/usage/install-module.html>`__ this module in a usual way
Configuration
=============
This module does not require special configuration.
Usage
=====

25
mail_reply/static/src/js/mail_reply.js

@ -2,13 +2,14 @@ odoo.define('mail_reply.reply', function (require) {
"use strict";
var core = require('web.core');
var base_obj = require('mail_base.base');
var chat_manager = require('mail_base.base').chat_manager;
var ChatAction = core.action_registry.get('mail.chat.instant_messaging');
ChatAction.include({
select_message: function(message_id) {
_selectMessage: function (message_id) {
this._super.apply(this, arguments);
var message = base_obj.chat_manager.get_message(message_id);
var message = chat_manager.get_message(message_id);
var subject = '';
if (message.record_name){
subject = "Re: " + message.record_name;
@ -17,9 +18,12 @@ ChatAction.include({
}
this.extended_composer.set_subject(subject);
},
on_post_message: function(message){
_onPostMessage: function (message) {
var self = this;
var options = this.selected_message ? {} : {channel_id: this.channel.id};
var options = this.selected_message
? {}
: {channel_id: this.channel.id};
if (this.selected_message) {
message.subtype = 'mail.mt_comment';
message.subtype_id = false;
@ -30,12 +34,11 @@ ChatAction.include({
options.res_id = this.selected_message.res_id;
options.parent_id = this.selected_message.id;
}
base_obj.chat_manager
.post_message(message, options)
.then(function() {
chat_manager.post_message(message, options).
then(function () {
if (self.selected_message) {
self.render_snackbar('mail.chat.MessageSentSnackbar', {record_name: self.selected_message.record_name}, 5000);
self.unselect_message();
self._renderSnackbar('mail.chat.MessageSentSnackbar', {record_name: self.selected_message.record_name}, 5000);
self._unselectMessage();
} else {
self.thread.scroll_to();
}
@ -43,4 +46,6 @@ ChatAction.include({
}
});
return chat_manager;
});

4
mail_reply/static/src/xml/reply_button.xml

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<template>
<t t-extend="mail.ChatThread.Message">
<t t-jquery='i[class="fa fa-reply o_thread_message_reply"]' t-operation="replace">
<t t-jquery='i[class="fa fa-reply o_thread_icon o_thread_message_reply"]' t-operation="replace">
<i t-if="message.author_id != 'ODOOBOT' &amp;&amp; message.model != 'mail.channel' &amp;&amp; options.display_reply_icon"
class="fa fa-reply o_thread_message_reply"
class="fa fa-reply o_thread_icon o_thread_message_reply"
t-att-data-message-id="message.id" title="Reply"/>
</t>
</t>

3
mail_reply/tests/__init__.py

@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import test_default

40
mail_reply/tests/test_default.py

@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
import odoo.tests
@odoo.tests.common.at_install(False)
@odoo.tests.common.post_install(True)
class TestUi(odoo.tests.HttpCase):
def test_01_mail_all(self):
# wait till page loaded and then click and wait again
code = """
setTimeout(function () {
var reply_button = $('.o_mail_info:not(:has(.o_document_link))').find(".fa.fa-reply.o_thread_icon.o_thread_message_reply");
if (reply_button.length === 0) {
console.log('error');
}
reply_button[0].click();
setTimeout(function () {
var send_button = $(".btn.btn-sm.btn-primary.o_composer_button_send.hidden-xs:visible");
if (send_button.length === 0) {
console.log('error');
}
$("textarea.o_input.o_composer_text_field")[1].value = 'test';
send_button.click();
setTimeout(function () {
if ($(".alert.o_mail_snackbar:visible").length === 0) {
console.log('error');
} else {
console.log('ok');
}
}, 1000);
}, 3000);
}, 1000);
"""
link = '/web#action=%s' % self.ref('mail.mail_channel_action_client_chat')
self.phantom_js(link, code, "odoo.__DEBUG__.services['mail_reply.reply']", login="admin")

42
mail_sent/README.rst

@ -1,16 +1,40 @@
Sentbox
=========
Sentbox
=========
Adds Sent menu, which shows sent messages.
Credits
=======
Adds Sent menu, which shows sent messages
Contributors
------------
* `Ivan Yelizariev <https://it-projects.info/team/yelizariev>`__
* Pavel Romanchenko <apps@it-projects.info>
Sponsors
--------
* `IT-Projects LLC <https://it-projects.info>`__
Maintainers
-----------
* `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/>`__.
Usage
-----
Click Discuss/Sent menu -- sent messages are displayed
Thank you for understanding!
`IT-Projects Team <https://www.it-projects.info/team>`__
Further information
-------------------
Further information and discussion: https://yelizariev.github.io/odoo/module/2015/02/19/sentbox.html
===================
Demo: http://runbot.it-projects.info/demo/mail_addons/11.0
HTML Description: https://apps.odoo.com/apps/modules/11.0/mail_sent/
Usage instructions: `<doc/index.rst>`_
HTML Description: https://apps.odoo.com/apps/modules/9.0/mail_sent/
Changelog: `<doc/changelog.rst>`_
Tested on Odoo 9.0 b9f206953e3f877adf18643f154d1262842564ee
Tested on Odoo 11.0 ecbf7aa4714479229658d14cce28fa00376ed390

2
mail_sent/__openerp__.py

@ -25,5 +25,5 @@
"qweb": [
"static/src/xml/menu.xml",
],
'installable': False,
'installable': True,
}

19
mail_sent/doc/index.rst

@ -0,0 +1,19 @@
=========
Sentbox
=========
Installation
============
* `Install <https://odoo-development.readthedocs.io/en/latest/odoo/usage/install-module.html>`__ this module in a usual way
Configuration
=============
This module does not require special configuration.
Usage
=====
* Open menu ``Discuss / Sent``
* You see sent messages

2
mail_sent/models.py

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from openerp import api, models, fields
from odoo import api, models, fields
class MailMessage(models.Model):

3
mail_sent/static/src/css/sent.css

@ -0,0 +1,3 @@
.o_channel_name.mail_sent i {
margin-right: 4px;
}

80
mail_sent/static/src/js/sent.js

@ -1,24 +1,16 @@
odoo.define('mail_sent.sent', function (require) {
"use strict";
var base_obj = require('mail_base.base');
//-------------------------------------------------------------------------------
var bus = require('bus.bus').bus;
var config = require('web.config');
var core = require('web.core');
var data = require('web.data');
var Model = require('web.Model');
var session = require('web.session');
var time = require('web.time');
var web_client = require('web.web_client');
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) {
init: function (parent, action, options) {
this._super.apply(this, arguments);
var channel_name = 'channel_sent';
// Add channel Sent for show "Send message" button
@ -27,7 +19,7 @@ ChatAction.include({
this.channels_display_subject.push(channel_name);
},
update_message_on_current_channel: function(current_channel_id, message){
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;
@ -35,45 +27,43 @@ ChatAction.include({
});
// Inherit class and override methods
base_obj.MailTools.include({
get_properties: function(msg){
var properties = this._super.apply(this, arguments);
properties.is_sent = this.property_descr("channel_sent", msg, this);
return properties;
},
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;
};
set_channel_flags: function(data, msg){
this._super.apply(this, arguments);
if (data.sent && data.author_id[0] == session.partner_id) {
msg.is_sent = true;
}
return msg;
},
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;
}
return msg;
};
get_channel_array: function(msg){
var arr = this._super.apply(this, arguments);
return arr.concat('channel_sent');
},
chat_manager.get_channel_array = function (msg) {
var arr = chat_manager_super.get_channel_array.apply(this, arguments);
return arr.concat('channel_sent');
};
get_domain: function(channel){
return (channel.id === "channel_sent") ? [
['sent', '=', true],
['author_id.user_ids', 'in', [openerp.session.uid]]
] : this._super.apply(this, arguments);
}
});
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);
};
base_obj.chat_manager.is_ready.then(function(){
// Add sent channel
base_obj.chat_manager.mail_tools.add_channel({
id: "channel_sent",
name: _lt("Sent"),
type: "static"
});
return $.when();
chat_manager.is_ready.then(function () {
// Add sent channel
chat_manager.add_channel({
id: "channel_sent",
name: _lt("Sent"),
type: "static"
});
return $.when();
});
return base_obj.chat_manager;
return chat_manager;
});

2
mail_sent/static/src/xml/menu.xml

@ -3,7 +3,7 @@
<!--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_channel_item #{(active_channel_id == 'channel_sent') ? 'o_active': ''}" data-channel-id="channel_sent">
<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">
<span class="o_channel_name mail_sent"> <i class="fa fa-send-o"/> Sent </span>
</div>
</t>

1
mail_sent/views/templates.xml

@ -5,6 +5,7 @@
name="mail_sent_assets_backend"
inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<link rel="stylesheet" href="/mail_sent/static/src/css/sent.css"/>
<script src="/mail_sent/static/src/js/sent.js" type="text/javascript"></script>
</xpath>
</template>

13
mail_to/README.rst

@ -19,14 +19,21 @@ Maintainers
-----------
* `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_to/>`__.
Thank you for understanding!
`IT-Projects Team <https://www.it-projects.info/team>`__
Further information
===================
Demo: http://runbot.it-projects.info/demo/mail-addons/10.0
HTML Description: https://apps.odoo.com/apps/modules/10.0/mail_to/
Demo: http://runbot.it-projects.info/demo/mail-addons/11.0
HTML Description: https://apps.odoo.com/apps/modules/11.0/mail_to/
Usage instructions: `<doc/index.rst>`_
Changelog: `<doc/changelog.rst>`_
Tested on Odoo 10.0 ffba5c688ff74a0630f9f70be1d7760a43a7deba
Tested on Odoo 11.0 ecbf7aa4714479229658d14cce28fa00376ed390

2
mail_to/__openerp__.py

@ -24,6 +24,6 @@
'static/src/xml/recipient.xml',
],
"demo": [],
"installable": False,
"installable": True,
"auto_install": False,
}

47
mail_to/static/src/js/mail_to.js

@ -1,31 +1,30 @@
odoo.define('mail_to.MailTo', function (require) {
"use strict";
var base_obj = require('mail_base.base');
var chat_manager = require('mail_base.base').chat_manager;
base_obj.MailTools.include({
make_message: function(data){
var msg = this._super(data);
msg.partner_ids = data.partner_ids;
if (!msg.partner_ids) {
return msg;
var make_message_super = chat_manager.make_message;
chat_manager.make_message = function (data) {
var msg = make_message_super.call(this, data);
msg.partner_ids = data.partner_ids;
if (!msg.partner_ids) {
return msg;
}
var more_recipients = '';
// value which define more recipients
msg.more_recipients_value = 4;
for (var i = 0; i < msg.partner_ids.length; i++) {
if (i >= msg.more_recipients_value) {
// append names
more_recipients += msg.partner_ids[i][1];
// separate them with semicolon
if (i < msg.partner_ids.length - 1){
more_recipients += '; ';
}
var more_recipients = '';
// value which define more recipients
msg.more_recipients_value = 4;
for (var i = 0; i < msg.partner_ids.length; i++){
if (i >= msg.more_recipients_value){
// append names
more_recipients += msg.partner_ids[i][1];
// separate them with semicolon
if (i < msg.partner_ids.length - 1){
more_recipients += '; ';
}
}
}
msg.more_recipients = more_recipients;
return msg;
}
});
}
msg.more_recipients = more_recipients;
return msg;
};
return chat_manager;
});

1
mail_to/tests/__init__.py

@ -0,0 +1 @@
from . import test_default

17
mail_to/tests/test_default.py

@ -0,0 +1,17 @@
import odoo.tests
@odoo.tests.common.at_install(False)
@odoo.tests.common.post_install(True)
class TestUi(odoo.tests.HttpCase):
def test_01_mail_to(self):
# checks the presence of an element with a link to the recipient
code = """
setTimeout(function () {
$('a.recipient_link')[0].click();
console.log('ok');
}, 1000);
"""
link = '/web#action=%s' % self.ref('mail.mail_channel_action_client_chat')
self.phantom_js(link, code, "odoo.__DEBUG__.services['mail_to.MailTo']", login="admin")
Loading…
Cancel
Save