Merge pull request #38 from x620/mail-addons-9.0-res_partner_mails_count
[PORT] to 9.0 Sendboxpull/6/head
-
2mail_archives/README.rst
-
4mail_archives/__openerp__.py
-
12mail_base/static/src/js/base.js
-
12mail_sent/README.rst
-
2mail_sent/__init__.py
-
35mail_sent/__openerp__.py
-
40mail_sent/models.py
-
BINmail_sent/static/description/menu.png
-
BINmail_sent/static/description/messages.png
-
61mail_sent/static/src/js/sent.js
-
20mail_sent/static/src/xml/menu.xml
-
38mail_sent/views.xml
-
12mail_sent/views/templates.xml
@ -1,8 +1,16 @@ |
|||||
Sentbox |
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 |
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 |
@ -1 +1,3 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
|
||||
import models |
import models |
@ -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', |
|
||||
|
"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': 9.00, |
'price': 9.00, |
||||
'currency': 'EUR', |
'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, |
||||
} |
} |
@ -1,28 +1,32 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
from openerp import api, models, fields |
from openerp import api, models, fields |
||||
|
|
||||
|
|
||||
class mail_message(models.Model): |
|
||||
|
class MailMessage(models.Model): |
||||
_inherit = 'mail.message' |
_inherit = 'mail.message' |
||||
|
|
||||
|
sent = fields.Boolean('Sent', compute="_get_sent", help='Was message sent to someone', store=True) |
||||
|
|
||||
@api.one |
@api.one |
||||
@api.depends('author_id', 'notified_partner_ids') |
|
||||
|
@api.depends('author_id', 'needaction_partner_ids') |
||||
def _get_sent(self): |
def _get_sent(self): |
||||
self_sudo = self.sudo() |
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.needaction_partner_ids) > 1 \ |
||||
|
or len(self_sudo.needaction_partner_ids) == 1 \ |
||||
|
and self_sudo.author_id \ |
||||
|
and self_sudo.needaction_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' |
_inherit = 'mail.compose.message' |
||||
sent = fields.Boolean('Sent', help='dummy field to fix inherit error') |
sent = fields.Boolean('Sent', help='dummy field to fix inherit error') |
||||
|
|
Before Width: 217 | Height: 167 | Size: 5.8 KiB After Width: 217 | Height: 167 | Size: 8.9 KiB |
Before Width: 625 | Height: 217 | Size: 37 KiB After Width: 625 | Height: 217 | Size: 39 KiB |
@ -0,0 +1,61 @@ |
|||||
|
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 _t = core._t; |
||||
|
//-------------------------------------------------------------------------------
|
||||
|
|
||||
|
// 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: _t("Sent"), |
||||
|
type: "static" |
||||
|
}); |
||||
|
|
||||
|
return $.when(); |
||||
|
}); |
||||
|
|
||||
|
return base_obj.chat_manager; |
||||
|
|
||||
|
}); |
@ -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"> <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> |
@ -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=""{ |
|
||||
'domain': [ |
|
||||
('author_id.user_ids', 'in', [uid]), |
|
||||
('sent', '=', True), |
|
||||
], |
|
||||
'view_mailbox': True, |
|
||||
'show_compose_message': False |
|
||||
}""/> |
|
||||
<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> |
|
@ -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> |