Browse Source

⬆️1️⃣2️⃣ mail_all

pull/166/head
KolushovAlexandr 6 years ago
parent
commit
0a5533f1f7
No known key found for this signature in database GPG Key ID: C3E04B793421FD2
  1. 8
      mail_all/README.rst
  2. 1
      mail_all/__init__.py
  3. 10
      mail_all/__manifest__.py
  4. 16
      mail_all/static/description/index.html
  5. 89
      mail_all/static/src/js/mail_all.js
  6. 17
      mail_all/static/src/xml/menu.xml
  7. 1
      mail_all/tests/__init__.py
  8. 4
      mail_all/tests/test_js.py
  9. 10
      mail_all/views/templates.xml

8
mail_all/README.rst

@ -1,8 +1,12 @@
.. image:: https://img.shields.io/badge/license-LGPL--3-blue.png
:target: https://www.gnu.org/licenses/lgpl
:alt: License: LGPL-3
===================
Show all messages
===================
Adds ``Discuss / All`` menu, that shows all messages accesable by current user.
Adds ``Discuss / All`` menu, that shows all messages accessible by current user.
Credits
=======
@ -36,4 +40,4 @@ Usage instructions: `<doc/index.rst>`_
Changelog: `<doc/changelog.rst>`_
Tested on Odoo 11.0 ecbf7aa4714479229658d14cce28fa00376ed390
Tested on Odoo 12.0 80cef9e8c52ff7dc0715a7478a2288d3de7065df

1
mail_all/__init__.py

@ -0,0 +1 @@
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

10
mail_all/__openerp__.py → mail_all/__manifest__.py

@ -1,10 +1,14 @@
# Copyright 2016-2018 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
# Copyright 2017-2018 Artyom Losev <https://it-projects.info/team/ArtyomLosev>
# Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
{
"name": "Show all messages",
"summary": """Checkout all messages where you have access""",
"category": "Discuss",
# "live_test_url": "",
"images": ['images/1.jpg'],
"version": "11.0.1.0.0",
"version": "12.0.1.0.0",
"application": False,
"author": "IT-Projects LLC, Pavel Romanchenko",
@ -15,7 +19,7 @@
'currency': 'EUR',
"depends": [
"mail_base"
"mail"
],
"external_dependencies": {"python": [], "bin": []},
"data": [
@ -31,6 +35,6 @@
"post_init_hook": None,
"uninstall_hook": None,
'installable': False,
'installable': True,
"auto_install": False,
}

16
mail_all/static/description/index.html

@ -59,9 +59,9 @@ This menu shows all messages.
-o-transform: rotate(6deg);
-moz-transform: rotate(6deg);
-ms-transform: rotate(6deg);">
Tested on Odoo<br/>10.0 community
Tested on Odoo<br/>12.0 community
</div>
<div style="margin-top: 15px;
<!--<div style="margin-top: 15px;
position: relative;
font-family:'Vollkorn', serif;
font-size: 16px;
@ -72,12 +72,12 @@ This menu shows all messages.
border: 3px dashed #75526b;
float: left;
padding: 4px 12px;
-webkit-transform: rotate(-3deg);
-o-transform: rotate(-3deg);
-moz-transform: rotate(-3deg);
-ms-transform: rotate(-3deg);">
Tested on Odoo<br/>10.0 enterprise
</div>
-webkit-transform: rotate(-3deg);
-o-transform: rotate(-3deg);
-moz-transform: rotate(-3deg);
-ms-transform: rotate(-3deg);">
Tested on Odoo<br/>12.0 enterprise
</div>-->
</div>
</div>
</div>

89
mail_all/static/src/js/mail_all.js

@ -1,57 +1,50 @@
/* # Copyright 2016-2018 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
# Copyright 2017-2018 Artyom Losev <https://it-projects.info/team/ArtyomLosev>
# Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). */
odoo.define('mail_all.all', function (require) {
"use strict";
var chat_manager = require('mail_base.base').chat_manager;
var core = require('web.core');
var _lt = core._lt;
var ChatAction = core.action_registry.get('mail.chat.instant_messaging');
ChatAction.include({
get_thread_rendering_options: function (messages) {
var options = this._super.apply(this, arguments);
options.display_subject = options.display_subject || this.channel.id === "channel_all";
return options;
}
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_all';
})) {
this._addMailbox({
id: 'channel_all',
name: _t("All Messages"),
mailboxCounter: data.needaction_inbox_counter || 0,
});
}
},
_makeMessage: function (data) {
var message = this._super(data);
message._addThread('mailbox_channel_all');
return message;
},
});
// 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_all = this.property_descr("channel_all", msg, this);
return properties;
};
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;
};
chat_manager.get_channel_array = function (msg) {
var arr = chat_manager_super.get_channel_array.apply(this, arguments);
return arr.concat('channel_all');
};
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
chat_manager.add_channel({
id: "channel_all",
name: _lt("All messages"),
type: "static"
});
return $.when();
});
Mailbox.include({
_getThreadDomain: function () {
if (this._id === 'mailbox_channel_all') {
return [];
}
return this._super();
},
});
return chat_manager;
return {
'Manager': Manager,
'Mailbox': Mailbox,
};
});

17
mail_all/static/src/xml/menu.xml

@ -1,17 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--# Copyright 2018 Artyom Losev <https://it-projects.info/team/ArtyomLosev>
# Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -->
<template>
<!--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_title_main o_mail_chat_channel_item #{(active_channel_id == 'channel_all') ? 'o_active': ''}" data-channel-id="channel_all">
<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_all o_mail_discuss_item #{(activeThreadID == 'channel_all') ? 'o_active': ''}" data-thread-id="mailbox_channel_all">
<span class="o_channel_name mail_all"> <i class="fa fa-database"/> All messages </span>
<t t-set="counter" t-value="starredCounter"/>
<t t-call="mail.discuss.SidebarCounter"/>
</div>
</t>
</t>
<!--Add message about empty all messages page-->
<t t-extend="mail.EmptyChannel">
<t t-jquery="t:last-child" t-operation="after">
<t t-if="options.channel_id==='channel_all'">
<t t-extend="mail.widget.Thread.Empty">
<t t-jquery="t:last" t-operation="after">
<t t-if="thread.getID() === 'mailbox_channel_all'">
<div class="o_thread_title">No messages</div>
</t>
</t>

1
mail_all/tests/__init__.py

@ -1,2 +1,3 @@
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from . import test_js

4
mail_all/tests/test_js.py

@ -1,3 +1,7 @@
# Copyright 2016 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
# Copyright 2016 manawi <https://it-projects.info/team/manawi>
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
import odoo.tests

10
mail_all/views/templates.xml

@ -1,6 +1,9 @@
<?xml version="1.0"?>
<openerp>
<data>
<!--# Copyright 2016 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
# Copyright 2018 Artyom Losev <https://it-projects.info/team/ArtyomLosev>
# Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -->
<odoo>
<template id="mail_all_assets_backend"
name="mail_all_assets_backend"
inherit_id="web.assets_backend">
@ -9,5 +12,4 @@
<script src="/mail_all/static/src/js/mail_all.js" type="text/javascript"></script>
</xpath>
</template>
</data>
</openerp>
</odoo>
Loading…
Cancel
Save