Browse Source

Merge pull request #4 from yelizariev/9.0-res_partner_mails_count

9.0 res partner mails count
pull/24/head
Ivan Yelizariev 8 years ago
parent
commit
1d09b52d76
  1. 16
      mail_all/README.rst
  2. 3
      mail_all/__init__.py
  3. 28
      mail_all/__openerp__.py
  4. 7
      mail_all/doc/changelog.rst
  5. 9
      mail_all/doc/index.rst
  6. 1
      mail_all/models/__init__.py
  7. BIN
      mail_all/static/description/1.png
  8. BIN
      mail_all/static/description/2.png
  9. BIN
      mail_all/static/description/icon.png
  10. 45
      mail_all/static/description/index.html
  11. 65
      mail_all/static/src/js/mail_all.js
  12. 19
      mail_all/static/src/xml/menu.xml
  13. 3
      mail_all/tests/__init__.py
  14. 15
      mail_all/tests/test_js.py
  15. 12
      mail_all/views/templates.xml
  16. 15
      mail_archives/README.rst
  17. 1
      mail_archives/__init__.py
  18. 26
      mail_archives/__openerp__.py
  19. BIN
      mail_archives/images/1.jpg
  20. BIN
      mail_archives/static/description/1.png
  21. BIN
      mail_archives/static/description/2.png
  22. BIN
      mail_archives/static/description/icon.png
  23. 45
      mail_archives/static/description/index.html
  24. 79
      mail_archives/static/src/js/archives.js
  25. 19
      mail_archives/static/src/xml/menu.xml
  26. 3
      mail_archives/tests/__init__.py
  27. 15
      mail_archives/tests/test_js.py
  28. 12
      mail_archives/views/templates.xml
  29. 19
      mail_base/README.rst
  30. 3
      mail_base/__init__.py
  31. 24
      mail_base/__openerp__.py
  32. 18
      mail_base/models.py
  33. 1140
      mail_base/static/src/js/base.js
  34. 12
      mail_base/views/templates.xml
  35. 2
      mail_fix_553/README.rst
  36. 12
      mail_sent/README.rst
  37. 2
      mail_sent/__init__.py
  38. 37
      mail_sent/__openerp__.py
  39. 40
      mail_sent/models.py
  40. BIN
      mail_sent/static/description/menu.png
  41. BIN
      mail_sent/static/description/messages.png
  42. 73
      mail_sent/static/src/js/sent.js
  43. 20
      mail_sent/static/src/xml/menu.xml
  44. 3
      mail_sent/tests/__init__.py
  45. 15
      mail_sent/tests/test_js.py
  46. 38
      mail_sent/views.xml
  47. 12
      mail_sent/views/templates.xml
  48. 11
      mail_to/README.rst
  49. 1
      mail_to/__init__.py
  50. 28
      mail_to/__openerp__.py
  51. 7
      mail_to/doc/changelog.rst
  52. 12
      mail_to/doc/index.rst
  53. 23
      mail_to/static/src/css/mail_to.css
  54. 29
      mail_to/static/src/js/mail_to.js
  55. 22
      mail_to/static/src/xml/recipient.xml
  56. 13
      mail_to/templates.xml
  57. 16
      res_partner_mails_count/README.rst
  58. 2
      res_partner_mails_count/__init__.py
  59. 28
      res_partner_mails_count/__openerp__.py
  60. BIN
      res_partner_mails_count/images/1.png
  61. 19
      res_partner_mails_count/models.py
  62. BIN
      res_partner_mails_count/static/description/1.png
  63. BIN
      res_partner_mails_count/static/description/2.png
  64. BIN
      res_partner_mails_count/static/description/3.png
  65. BIN
      res_partner_mails_count/static/description/icon.png
  66. 34
      res_partner_mails_count/static/description/index.html
  67. 36
      res_partner_mails_count/static/src/js/res_partner_mails_count_tour.js
  68. 47
      res_partner_mails_count/templates.xml
  69. 4
      res_partner_mails_count/tests/__init__.py
  70. 33
      res_partner_mails_count/tests/test_mail.py
  71. 19
      res_partner_mails_count/tests/test_phantom.py
  72. 18
      res_partner_mails_count/views/res_partner_mails_count.xml

16
mail_all/README.rst

@ -0,0 +1,16 @@
===================
Show all messages
===================
Adds ``Discuss / All`` menu, that shows all messages accesable by current user
Further information
-------------------
HTML Description: https://apps.odoo.com/apps/modules/9.0/mail_all/
Usage instructions: `<doc/index.rst>`_
Changelog: `<doc/changelog.rst>`_
Tested on Odoo 9.0 d3dd4161ad0598ebaa659fbd083457c77aa9448d

3
mail_all/__init__.py

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

28
mail_all/__openerp__.py

@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
{
"name": "Show all messages",
"summary": """Checkout all messages where you have access""",
"category": "Discuss",
"images": [],
"version": "1.0.0",
"author": "IT-Projects LLC, Pavel Romanchenko",
"website": "https://it-projects.info",
"license": "LGPL-3",
'price': 40.00,
'currency': 'EUR',
"depends": [
"mail_base"
],
"external_dependencies": {"python": [], "bin": []},
"data": [
"views/templates.xml",
],
"qweb": [
"static/src/xml/menu.xml",
],
"demo": [],
'installable': True,
"auto_install": False,
}

7
mail_all/doc/changelog.rst

@ -0,0 +1,7 @@
Changelog
=========
`1.0.0`
-------
- Init version

9
mail_all/doc/index.rst

@ -0,0 +1,9 @@
===================
Show all messages
===================
Usage
=====
* Open menu ``Discuss / All messages``
* You see all messages

1
mail_all/models/__init__.py

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

BIN
mail_all/static/description/1.png

After

Width: 300  |  Height: 270  |  Size: 15 KiB

BIN
mail_all/static/description/2.png

After

Width: 765  |  Height: 400  |  Size: 22 KiB

BIN
mail_all/static/description/icon.png

After

Width: 100  |  Height: 100  |  Size: 2.1 KiB

45
mail_all/static/description/index.html

@ -0,0 +1,45 @@
<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<h2 class="oe_slogan">Show all messages</h2>
<h3 class="oe_slogan">Checkout all messages where you have access</h3>
</div>
<div class="oe_span6">
<div class="oe_row_img oe_centered">
<img class="oe_picture oe_screenshot" src="1.png"/>
</div>
</div>
<div class="oe_span6">
<p class="oe_mt32">
The module adds usual menu.
</p>
</div>
</div>
</section>
<section class="oe_container oe_dark">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<p class="oe_mt32">
This menu shows all messages.
</p>
</div>
<div class="oe_row_img oe_centered">
<img class="oe_picture oe_screenshot" src="2.png"/>
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<h2>Need our service?</h2>
<p class="oe_mt32">Contact us by <a href="mailto:it@it-projects.info">email</a> or fill out <a href="https://www.it-projects.info/page/website.contactus " target="_blank">request form</a></p>
<ul>
<li><a href="mailto:it@it-projects.info">it@it-projects.info <i class="fa fa-envelope-o"></i></a></li>
<li><a href="https://www.it-projects.info/page/website.contactus " target="_blank">
https://www.it-projects.info/page/website.contactus <i class="fa fa-list-alt"></i></a></li>
</ul>
</div>
</div>
</section>

65
mail_all/static/src/js/mail_all.js

@ -0,0 +1,65 @@
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 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({
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;
}
});
// 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;
},
set_channel_flags: function(data, msg){
this._super.apply(this, arguments);
msg.is_all = true;
return msg;
},
get_channel_array: function(msg){
var arr = this._super.apply(this, arguments);
return arr.concat('channel_all');
},
get_domain: function(channel){
return (channel.id === "channel_all") ? [] : this._super.apply(this, arguments);
}
});
base_obj.chat_manager.is_ready.then(function(){
// Add all channel
base_obj.chat_manager.mail_tools.add_channel({
id: "channel_all",
name: _lt("All messages"),
type: "static"
});
return $.when();
});
return base_obj.chat_manager;
});

19
mail_all/static/src/xml/menu.xml

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<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_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>
</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'">
<div class="o_thread_title">No messages</div>
</t>
</t>
</t>
</template>

3
mail_all/tests/__init__.py

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

15
mail_all/tests/test_js.py

@ -0,0 +1,15 @@
import openerp.tests
@openerp.tests.common.at_install(False)
@openerp.tests.common.post_install(True)
class TestUi(openerp.tests.HttpCase):
def test_01_mail_all(self):
# wait till page loaded and then click and wait again
code = """
setTimeout(function () {
$(".mail_all").click();
setTimeout(function () {console.log('ok');}, 3000);
}, 1000);
"""
link = '/web#action=%s' % self.ref('mail.mail_channel_action_client_chat')
self.phantom_js(link, code, "odoo.__DEBUG__.services['mail_all.all']", login="admin")

12
mail_all/views/templates.xml

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<openerp>
<data>
<template id="mail_all_assets_backend"
name="mail_all_assets_backend"
inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script src="/mail_all/static/src/js/mail_all.js" type="text/javascript"></script>
</xpath>
</template>
</data>
</openerp>

15
mail_archives/README.rst

@ -0,0 +1,15 @@
Mail Archives
=============
Adds Archive menu, which shows sent/received messages
Usage
-----
Click Discuss/Archive menu -- sent/received messages are displayed
Further information
-------------------
HTML Description: https://apps.odoo.com/apps/modules/9.0/mail_archives/
Tested on Odoo 9.0 b9f206953e3f877adf18643f154d1262842564ee

1
mail_archives/__init__.py

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

26
mail_archives/__openerp__.py

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
{
"name": "Mail archives",
"summary": """Adds menu to find old messages""",
"category": "Discuss",
"images": [],
"version": "1.0.0",
"author": "IT-Projects LLC, Pavel Romanchenko",
"website": "https://it-projects.info",
"license": "LGPL-3",
'price': 40.00,
'currency': 'EUR',
"depends": [
"mail_base",
],
"data": [
"views/templates.xml",
],
"qweb": [
"static/src/xml/menu.xml",
],
'installable': True,
}

BIN
mail_archives/images/1.jpg

After

Width: 334  |  Height: 171  |  Size: 18 KiB

BIN
mail_archives/static/description/1.png

After

Width: 300  |  Height: 270  |  Size: 24 KiB

BIN
mail_archives/static/description/2.png

After

Width: 765  |  Height: 400  |  Size: 40 KiB

BIN
mail_archives/static/description/icon.png

After

Width: 100  |  Height: 100  |  Size: 2.1 KiB

45
mail_archives/static/description/index.html

@ -0,0 +1,45 @@
<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<h2 class="oe_slogan">Look up old mails</h2>
<h3 class="oe_slogan">Browse archived mails like in odoo 8</h3>
</div>
<div class="oe_span6">
<div class="oe_row_img oe_centered">
<img class="oe_picture oe_screenshot" src="1.png"/>
</div>
</div>
<div class="oe_span6">
<p class="oe_mt32">
The module adds usual menu.
</p>
</div>
</div>
</section>
<section class="oe_container oe_dark">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<p class="oe_mt32">
This menu shows archive messages, i.e. ones you sent or received.
</p>
</div>
<div class="oe_row_img oe_centered">
<img class="oe_picture oe_screenshot" src="2.png"/>
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<h2>Need our service?</h2>
<p class="oe_mt32">Contact us by <a href="mailto:it@it-projects.info">email</a> or fill out <a href="https://www.it-projects.info/page/website.contactus " target="_blank">request form</a></p>
<ul>
<li><a href="mailto:it@it-projects.info">it@it-projects.info <i class="fa fa-envelope-o"></i></a></li>
<li><a href="https://www.it-projects.info/page/website.contactus " target="_blank">
https://www.it-projects.info/page/website.contactus <i class="fa fa-list-alt"></i></a></li>
</ul>
</div>
</div>
</section>

79
mail_archives/static/src/js/archives.js

@ -0,0 +1,79 @@
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 _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_archive';
// Add channel Archive for enable "display_subject" option
this.channels_display_subject.push(channel_name);
}
});
// 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;
},
get_channel_array: function(msg){
var arr = this._super.apply(this, arguments);
return arr.concat('channel_archive');
},
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);
}
});
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"
});
return $.when();
});
return base_obj.chat_manager;
});

19
mail_archives/static/src/xml/menu.xml

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<template>
<!--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">
<span class="o_channel_name mail_archives"> <i class="fa fa-archive"/> Archive </span>
</div>
</t>
</t>
<!--Add message about empty archive page-->
<t t-extend="mail.EmptyChannel">
<t t-jquery="t:last-child" t-operation="after">
<t t-if="options.channel_id==='channel_archive'">
<div class="o_thread_title">Archive is empty</div>
</t>
</t>
</t>
</template>

3
mail_archives/tests/__init__.py

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

15
mail_archives/tests/test_js.py

@ -0,0 +1,15 @@
import openerp.tests
@openerp.tests.common.at_install(False)
@openerp.tests.common.post_install(True)
class TestUi(openerp.tests.HttpCase):
def test_01_mail_archives(self):
# wait till page loaded and then click and wait again
code = """
setTimeout(function () {
$(".mail_archives").click();
setTimeout(function () {console.log('ok');}, 3000);
}, 1000);
"""
link = '/web#action=%s' % self.ref('mail.mail_channel_action_client_chat')
self.phantom_js(link, code, "odoo.__DEBUG__.services['mail_archives.archives']", login="admin")

12
mail_archives/views/templates.xml

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<openerp>
<data>
<template id="res_partner_mails_count_assets_backend"
name="res_partner_mails_count_assets_backend"
inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script src="/mail_archives/static/src/js/archives.js" type="text/javascript"></script>
</xpath>
</template>
</data>
</openerp>

19
mail_base/README.rst

@ -0,0 +1,19 @@
Mail Base
=========
* makes built-in mail js features extendable.
* handles ``search_default_*`` parameters in context.
* fixes toggling left bar
* fixes Recipients field. Out-of-box this field could be empty.
Usage
-----
To use this module you need either install module that depends on it or create new module.
Further information
-------------------
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.
One can say, that the module do this todo from `addons/mail/static/src/js/chat_manager.js <https://github.com/odoo/odoo/blob/9.0/addons/mail/static/src/js/chat_manager.js#L57>`_
// to do: move this to mail.utils

3
mail_base/__init__.py

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

24
mail_base/__openerp__.py

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
{
"name": "Mail Base",
"summary": """Makes Mail extendable""",
"category": "Discuss",
"images": [],
"version": "1.0.0",
"author": "IT-Projects LLC, Pavel Romanchenko",
"website": "https://it-projects.info",
"license": "LGPL-3",
'price': 9.00,
'currency': 'EUR',
"depends": [
"base",
"mail"
],
"data": [
"views/templates.xml",
],
'installable': True,
}

18
mail_base/models.py

@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
from openerp import api, models
class MailMessage(models.Model):
_inherit = 'mail.message'
@api.multi
def write(self, values):
if values.get('needaction_partner_ids'):
if not values.get('partner_ids'):
values['partner_ids'] = []
for triplet in values.get('needaction_partner_ids'):
if triplet[0] == 6:
for id in triplet[2]:
values['partner_ids'].append((4, id, False))
return super(MailMessage, self).write(values)

1140
mail_base/static/src/js/base.js
File diff suppressed because it is too large
View File

12
mail_base/views/templates.xml

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<openerp>
<data>
<template id="mail_base_assets_backend"
name="mail_base_assets_backend"
inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script src="/mail_base/static/src/js/base.js" type="text/javascript"></script>
</xpath>
</template>
</data>
</openerp>

2
mail_fix_553/README.rst

@ -20,6 +20,8 @@ Configuration
You can configure default alias at Settings -> System Parameters -> mail.catchall.alias_from
You can configure name for default alias at Settings -> System Parameters -> mail.catchall.name_alias_from
You can configure name for default alias at Settings -> System Parameters -> mail.catchall.name_alias_from
Known issues / Roadmap
======================

12
mail_sent/README.rst

@ -1,8 +1,16 @@
Sentbox
=======
Description: https://apps.odoo.com/apps/modules/8.0/mail_sent/
Adds Sent menu, which shows sent messages
Usage
-----
Click Discuss/Sent menu -- sent messages are displayed
Further information
-------------------
Further information and discussion: https://yelizariev.github.io/odoo/module/2015/02/19/sentbox.html
Tested on Odoo 8.0 231e02693640325c9a05fa31c680063b9e4b017b
HTML Description: https://apps.odoo.com/apps/modules/9.0/mail_sent/
Tested on Odoo 9.0 b9f206953e3f877adf18643f154d1262842564ee

2
mail_sent/__init__.py

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

37
mail_sent/__openerp__.py

@ -1,15 +1,28 @@
# -*- coding: utf-8 -*-
{
'name' : 'Sentbox',
'version' : '1.0.2',
'author' : 'IT-Projects LLC, Ivan Yelizariev',
'license': 'LGPL-3',
'category' : 'Social Network',
'website' : 'https://twitter.com/yelizariev',
'price': 9.00,
"name": "Sentbox",
"summary": """Quick way to find sent messages""",
"category": "Discuss",
"images": [],
"version": "1.0.3",
"author": "IT-Projects LLC, Ivan Yelizariev, Pavel Romanchenko",
"website": "https://it-projects.info",
"license": "LGPL-3",
'price': 40.00,
'currency': 'EUR',
'depends' : ['mail'],
'data':[
'views.xml',
],
'installable': False
"depends": [
"base",
"mail",
"mail_base"
],
"data": [
"views/templates.xml",
],
"qweb": [
"static/src/xml/menu.xml",
],
'installable': True,
}

40
mail_sent/models.py

@ -1,28 +1,32 @@
# -*- coding: utf-8 -*-
from openerp import api, models, fields
class mail_message(models.Model):
class MailMessage(models.Model):
_inherit = 'mail.message'
sent = fields.Boolean('Sent', compute="_get_sent", help='Was message sent to someone', store=True)
@api.one
@api.depends('author_id', 'notified_partner_ids')
@api.depends('author_id', 'partner_ids')
def _get_sent(self):
self_sudo = self.sudo()
self_sudo.sent = len(self_sudo.notified_partner_ids) > 1 or len(self_sudo.notified_partner_ids) == 1 and self_sudo.author_id and self_sudo.notified_partner_ids[0].id != self_sudo.author_id.id
sent = fields.Boolean('Sent', compute=_get_sent, help='Was message sent to someone', store=True)
class mail_notification(models.Model):
_inherit = 'mail.notification'
def _notify(self, cr, uid, message_id, **kwargs):
super(mail_notification, self)._notify(cr, uid, message_id, **kwargs)
self.pool['mail.message'].browse(cr, uid, message_id)._get_sent()
class mail_compose_message(models.TransientModel):
self_sudo.sent = len(self_sudo.partner_ids) > 1 \
or len(self_sudo.partner_ids) == 1 \
and self_sudo.author_id \
and self_sudo.partner_ids[0].id != self_sudo.author_id.id
@api.multi
def message_format(self):
message_values = super(MailMessage, self).message_format()
message_index = {message['id']: message for message in message_values}
for item in self:
msg = message_index.get(item.id)
if msg:
msg['sent'] = item.sent
return message_values
class MailComposeMessage(models.TransientModel):
_inherit = 'mail.compose.message'
sent = fields.Boolean('Sent', help='dummy field to fix inherit error')

BIN
mail_sent/static/description/menu.png

Before

Width: 217  |  Height: 167  |  Size: 5.8 KiB

After

Width: 217  |  Height: 167  |  Size: 8.9 KiB

BIN
mail_sent/static/description/messages.png

Before

Width: 625  |  Height: 217  |  Size: 37 KiB

After

Width: 625  |  Height: 217  |  Size: 39 KiB

73
mail_sent/static/src/js/sent.js

@ -0,0 +1,73 @@
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 _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);
}
});
// 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;
},
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;
},
get_channel_array: function(msg){
var arr = this._super.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);
}
});
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();
});
return base_obj.chat_manager;
});

20
mail_sent/static/src/xml/menu.xml

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<template>
<!--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">
<span class="o_channel_name mail_sent"> <i class="fa fa-send-o"/> Sent </span>
</div>
</t>
</t>
<!--Add message about empty sent page-->
<t t-extend="mail.EmptyChannel">
<t t-jquery="t:last-child" t-operation="after">
<t t-if="options.channel_id==='channel_sent'">
<div class="o_thread_title">No sent messages</div>
<div>You can send messages and then these messages will appear here.</div>
</t>
</t>
</t>
</template>

3
mail_sent/tests/__init__.py

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

15
mail_sent/tests/test_js.py

@ -0,0 +1,15 @@
import openerp.tests
@openerp.tests.common.at_install(False)
@openerp.tests.common.post_install(True)
class TestUi(openerp.tests.HttpCase):
def test_01_mail_sent(self):
# wait till page loaded and then click and wait again
code = """
setTimeout(function () {
$(".mail_sent").click();
setTimeout(function () {console.log('ok');}, 3000);
}, 1000);
"""
link = '/web#action=%s' % self.ref('mail.mail_channel_action_client_chat')
self.phantom_js(link, code, "odoo.__DEBUG__.services['mail_sent.sent']", login="demo")

38
mail_sent/views.xml

@ -1,38 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="action_mail_sent_feeds" model="ir.actions.client">
<field name="name">Sent</field>
<field name="tag">mail.wall</field>
<field name="context">{
'default_model': 'res.users',
'default_res_id': uid,
'thread_model': 'res.partner',
'needaction_menu_ref': ['mail.mail_tomefeeds', 'mail.mail_starfeeds', 'mail.mail_inboxfeeds']
}</field>
<field name="params" eval="&quot;{
'domain': [
('author_id.user_ids', 'in', [uid]),
('sent', '=', True),
],
'view_mailbox': True,
'show_compose_message': False
}&quot;"/>
<field name="help" type="html">
<p>
No message found and no message sent yet.
</p><p>
Click on the top-right icon to compose a message. This
message will be sent by email if it's an internal contact.
</p>
</field>
</record>
<record id="mail_sentfeeds" model="ir.ui.menu">
<field name="name">Sent</field>
<field name="sequence" eval="10"/>
<field name="action" ref="action_mail_sent_feeds"/>
<field name="parent_id" ref="mail.mail_feeds"/>
</record>
</data>
</openerp>

12
mail_sent/views/templates.xml

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<openerp>
<data>
<template id="mail_sent_assets_backend"
name="mail_sent_assets_backend"
inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script src="/mail_sent/static/src/js/sent.js" type="text/javascript"></script>
</xpath>
</template>
</data>
</openerp>

11
mail_to/README.rst

@ -0,0 +1,11 @@
=========================
Show message recipients
=========================
Allows you be sure, that all discussion participants were notified. Adds recipients label the right of message.
Further information
-------------------
HTML Description: https://apps.odoo.com/apps/modules/9.0/mail_to/
Tested on Odoo 9.0 d3dd4161ad0598ebaa659fbd083457c77aa9448d

1
mail_to/__init__.py

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

28
mail_to/__openerp__.py

@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
{
"name": """Show message recipients""",
"summary": """Allows you be sure, that all discussion participants were notified""",
"category": "Discuss",
"images": [],
"version": "1.0.0",
"author": "IT-Projects LLC, Pavel Romanchenko",
"website": "https://it-projects.info",
"license": "LGPL-3",
"price": 40.00,
"currency": "EUR",
"depends": [
'mail_base',
],
"external_dependencies": {"python": [], "bin": []},
"data": [
'templates.xml',
],
"qweb": [
'static/src/xml/recipient.xml',
],
"demo": [],
"installable": True,
"auto_install": False,
}

7
mail_to/doc/changelog.rst

@ -0,0 +1,7 @@
Changelog
=========
`1.0.0`
-------
- Init version

12
mail_to/doc/index.rst

@ -0,0 +1,12 @@
=========================
Show message recipients
=========================
Usage
=====
* Open Discuss menu.
* Many messages have Recipients info.
* Click Inbox left menu item, click Send mail button, set recipient and send message. This message will show recipient.
* To see the recipient's need hover the mouse over a message.
* For messages created before install module it will not work where the recipients are not set. There is no way to restore recipients value.

23
mail_to/static/src/css/mail_to.css

@ -0,0 +1,23 @@
.recipient_link {
color: grey;
}
.recipient_link:hover {
color: #0d0d0d;
}
.o_mail_thread .o_thread_message span.recipients_info,
.o_mail_thread .o_thread_message i.o_thread_message_star,
.o_mail_thread .o_thread_message i.o_thread_message_reply,
.o_mail_thread .o_thread_message i.o_thread_message_needaction {
opacity: 0.4;
}
.o_mail_thread .o_thread_message:hover i.o_thread_message_star,
.o_mail_thread .o_thread_message:hover i.o_thread_message_reply,
.o_mail_thread .o_thread_message:hover i.o_thread_message_needaction {
opacity: 0.7;
}
.o_mail_thread .o_thread_message:hover span.recipients_info {
opacity: 1;
}

29
mail_to/static/src/js/mail_to.js

@ -0,0 +1,29 @@
odoo.define('mail_to.MailTo', function (require) {
"use strict";
var base_obj = require('mail_base.base');
base_obj.MailTools.include({
make_message: function(data){
var msg = this._super(data);
msg.partner_ids = data.partner_ids;
// msg.needaction_partner_ids = data.needaction_partner_ids;
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;
}
});
});

22
mail_to/static/src/xml/recipient.xml

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<template>
<t t-extend="mail.ChatThread.Message">
<t t-jquery="p[class=o_mail_info]>span" t-operation="after">
<span class="recipients_info">
<t t-if="message.partner_ids.length > 0">To: </t>
<t t-foreach="message.partner_ids.length" t-as="i">
<t t-if="i &lt; message.more_recipients_value">
<a t-att-href="_.str.sprintf('/web?#id=%s&amp;view_type=form&amp;model=res.partner', message.partner_ids[i][0])" class="recipient_link">
<i t-esc="message.partner_ids[i][1]"/><t t-if="i &lt; message.partner_ids.length - 1">; </t>
</a>
</t>
</t>
<t t-if="message.partner_ids.length &gt; message.more_recipients_value - 1">
<span t-att-title="message.more_recipients">
and <t t-esc="message.partner_ids.length - message.more_recipients_value"/> more
</span>
</t>
</span>
</t>
</t>
</template>

13
mail_to/templates.xml

@ -0,0 +1,13 @@
<?xml version="1.0"?>
<openerp>
<data>
<template id="mail_to_assets_backend"
name="mail_to_assets_backend"
inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<link rel="stylesheet" href="/mail_to/static/src/css/mail_to.css"/>
<script src="/mail_to/static/src/js/mail_to.js" type="text/javascript"></script>
</xpath>
</template>
</data>
</openerp>

16
res_partner_mails_count/README.rst

@ -0,0 +1,16 @@
Smart buttons for mails count
=============================
This module adds Smart buttons with "Mails from" and "Mails to" count of mails in the partner form.
Usage
-----
You can see Smart buttons "Mails from" and "Mails to" in the contact form in the Messaging/Contacts menu. If you click on these buttons, you can see list of corresponded mails. Click on the "Send a message" link to send mail to the partner.
Further information
-------------------
HTML Description: https://apps.odoo.com/apps/modules/9.0/res_partner_mails_count/
Tested on Odoo 9.0 b9f206953e3f877adf18643f154d1262842564ee

2
res_partner_mails_count/__init__.py

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

28
res_partner_mails_count/__openerp__.py

@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
{
"name": """Partner mails count""",
"summary": """Displays amount of incoming and outgoing partner mails.""",
"category": "Sales Management",
"images": ['images/1.png'],
"version": "1.0.0",
"author": "IT-Projects LLC, Pavel Romanchenko",
"website": "https://it-projects.info",
"license": "LGPL-3",
"price": 30.00,
"currency": "EUR",
"depends": [
'mail_all',
'web_tour_extra',
],
"external_dependencies": {"python": [], "bin": []},
"data": [
'views/res_partner_mails_count.xml',
'templates.xml',
],
"demo": [
],
"installable": True,
"auto_install": False,
}

BIN
res_partner_mails_count/images/1.png

After

Width: 1128  |  Height: 528  |  Size: 92 KiB

19
res_partner_mails_count/models.py

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
from openerp import models, fields, api
class res_partner(models.Model):
_inherit = 'res.partner'
mails_to = fields.Integer(compute="_mails_to")
mails_from = fields.Integer(compute="_mails_from")
@api.one
def _mails_to(self):
for r in self:
r.mails_to = self.env['mail.message'].sudo().search_count([('partner_ids', 'in', r.id)])
@api.one
def _mails_from(self):
for r in self:
r.mails_from = self.env['mail.message'].sudo().search_count([('author_id', '=', r.id)])

BIN
res_partner_mails_count/static/description/1.png

After

Width: 1128  |  Height: 528  |  Size: 66 KiB

BIN
res_partner_mails_count/static/description/2.png

After

Width: 1128  |  Height: 528  |  Size: 63 KiB

BIN
res_partner_mails_count/static/description/3.png

After

Width: 1128  |  Height: 528  |  Size: 46 KiB

BIN
res_partner_mails_count/static/description/icon.png

After

Width: 100  |  Height: 100  |  Size: 2.1 KiB

34
res_partner_mails_count/static/description/index.html

@ -0,0 +1,34 @@
<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<h2 class="oe_slogan">Smart buttons for mails count</h2>
<h3 class="oe_slogan">Display amount of messages from/to customer</h3>
<p>
Open partner (customer) form and look up how many messages he got and sent:
<img class="oe_picture oe_screenshot" src="1.png"/>
</p>
<p>
If you click any of this buttons:
<img class="oe_picture oe_screenshot" src="2.png"/>
</p>
<p>
You will see those mails:
<img class="oe_picture oe_screenshot" src="3.png"/>
</p>
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<h2>Need our service?</h2>
<p class="oe_mt32">Contact us by <a href="mailto:it@it-projects.info">email</a> or fill out <a href="https://www.it-projects.info/page/website.contactus " target="_blank">request form</a></p>
<ul>
<li><a href="mailto:it@it-projects.info">it@it-projects.info <i class="fa fa-envelope-o"></i></a></li>
<li><a href="https://www.it-projects.info/page/website.contactus " target="_blank">
https://www.it-projects.info/page/website.contactus <i class="fa fa-list-alt"></i></a></li>
</ul>
</div>
</div>
</section>

36
res_partner_mails_count/static/src/js/res_partner_mails_count_tour.js

@ -0,0 +1,36 @@
odoo.define('res_partner_mails_count.res_partner_mails_count_tour', function (require) {
'use strict';
var Core = require('web.core');
var Tour = require('web.Tour');
var _t = Core._t;
Tour.register({
id: 'mails_count_tour',
name: _t("Mails count Tour"),
mode: 'test',
path: '/web?res_partner_mails_count=tutorial#id=3&view_type=form&model=res.partner',
steps: [
{
title: _t("Mails count tutorial"),
content: _t("Let's see how mails count work."),
popover: { next: _t("Start Tutorial"), end: _t("Skip") },
},
{
title: _t("New fields"),
content: _t("Here is new fields with mails counters. Press one of it."),
element: '.mails_to',
waitFor: '.mails_to:visible',
},
{
title: _t("Done"),
placement: 'top',
waitNot: '.mails_to:visible',
waitFor: '.o_mail_thread',
element: '.o_mail_thread',
content: _t("Message are found. <br/>Enjoy your day! <br/> <br/><a href='https://www.it-projects.info/apps' target='_blank'>IT-Projects LLC</a> team "),
popover: {next: _t("Close Tutorial")},
},
]
});
});

47
res_partner_mails_count/templates.xml

@ -0,0 +1,47 @@
<?xml version="1.0"?>
<openerp>
<data>
<template id="res_partner_mails_count_assets_backend"
inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script src="/res_partner_mails_count/static/src/js/res_partner_mails_count_tour.js"
type="text/javascript"></script>
</xpath>
</template>
<record id="view_res_partner_mails_count_info_form" model="ir.ui.view">
<field name="name">res.partner.mails.count</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="priority" eval="50"/>
<field name="arch" type="xml">
<div name="button_box" position="inside">
<button class="oe_stat_button mails_to" type="action"
name="%(action_mails)d"
context="{'search_default_partner_ids': [active_id], 'default_model': 'res.partner', 'default_res_id': active_id}"
icon="fa-envelope">
<field string="Mails to" name="mails_to" widget="statinfo"/>
</button>
<button class="oe_stat_button mails_from" type="action"
name="%(action_mails)d"
context="{'search_default_author_id': active_id, 'default_model': 'res.partner', 'default_res_id': active_id}"
icon="fa-envelope-o">
<field string="Mails from" name="mails_from" widget="statinfo"/>
</button>
</div>
</field>
</record>
<record id="res_partner_mails_count_tutorial" model="ir.actions.act_url">
<field name="name">res_partner_mails_count Tutorial</field>
<field name="url" eval="'/web?res_partner_mails_count=tutorial#id='+str(ref('base.partner_root'))+'&amp;view_type=form&amp;model=res.partner&amp;/#tutorial_extra.mails_count_tour=true'"/>
<field name="target">self</field>
</record>
</data>
<data noupdate="1">
<record id="base.open_menu" model="ir.actions.todo">
<field name="action_id" ref="res_partner_mails_count_tutorial"/>
<field name="state">open</field>
<field name="sequence">500</field>
<field name="type">automatic</field>
</record>
</data>
</openerp>

4
res_partner_mails_count/tests/__init__.py

@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
from . import test_mail
from . import test_phantom

33
res_partner_mails_count/tests/test_mail.py

@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
from openerp.tests.common import TransactionCase
class test_message_count(TransactionCase):
post_install = True
def test_count(self):
new_partner1 = self.env['res.partner'].sudo().create({'name': 'rpmc Test Partner one', 'email': 'tt@tt', 'notify_email': 'always'})
new_partner2 = self.env['res.partner'].sudo().create({'name': 'rpmc Test Partner two', 'email': 'rr@rr', 'notify_email': 'always'})
self.assertEqual(new_partner1.mails_to, 0, 'rpmc: new partner have mails_to != 0')
mail_compose = self.env['mail.compose.message']
compose = mail_compose.with_context(
{
'default_composition_mode': 'comment',
}).create(
{
'subject': 'test subj',
'body': 'test body',
'partner_ids': [(4, new_partner2.id)],
'email_from': 'tt@tt',
'author_id': new_partner1.id
})
compose.send_mail()
self.assertEqual(new_partner1.mails_to, 0)
self.assertEqual(new_partner1.mails_from, 1, 'rpmc: one message but mails_from != 1')
self.assertEqual(new_partner2.mails_to, 1, 'rpmc: one message but mails_to != 1')
self.assertEqual(new_partner2.mails_from, 0)
compose.send_mail()
self.assertEqual(new_partner1.mails_to, 0)
self.assertEqual(new_partner1.mails_from, 2, 'rpmc: one message but mails_from != 2')
self.assertEqual(new_partner2.mails_to, 2, 'rpmc: one message but mails_to != 2')
self.assertEqual(new_partner2.mails_from, 0)

19
res_partner_mails_count/tests/test_phantom.py

@ -0,0 +1,19 @@
import openerp.tests
@openerp.tests.common.at_install(False)
@openerp.tests.common.post_install(True)
class TestUi(openerp.tests.HttpCase):
def test_01_res_partner_mails_to_count(self):
# self.phantom_js('/', "openerp.Tour.run('mails_count_tour', 'test')", "openerp.Tour.tours.mails_count_tour", login="admin")
self.phantom_js("/", "odoo.__DEBUG__.services['web.Tour'].run('mails_count_tour', 'test')","odoo.__DEBUG__.services['web.Tour'].tours.mails_count_tour", login="admin")
def test_02_res_partner_mails_from_count(self):
# wait till page loaded and then click and wait again
code = """
setTimeout(function () {
$(".mails_from").click();
setTimeout(function () {console.log('ok');}, 3000);
}, 3000);
"""
link = '/web#id=3&view_type=form&model=res.partner'
self.phantom_js(link, code, "odoo.__DEBUG__.services['web.Tour'].tours.mails_count_tour", login="admin")

18
res_partner_mails_count/views/res_partner_mails_count.xml

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record id="action_mails" model="ir.actions.client">
<field name="name">Mails</field>
<field name="tag">mail.chat.instant_messaging</field>
<field name="res_model">mail.message</field>
<field name="context">{
'active_id': 'channel_all'
}</field>
<field name="help" type="html">
<p>
Mails not found. Probably, they exist, but you don't have access.
</p>
</field>
</record>
</data>
</openerp>
Loading…
Cancel
Save