Browse Source

Merge pull request #22 from x620/9.0-res_partner_mails_count

9.0-res_partner_mails_count
pull/23/head
Ivan Yelizariev 9 years ago
parent
commit
0bf880806a
  1. 4
      mail_archives/README.rst
  2. 2
      mail_archives/__init__.py
  3. 4
      mail_archives/__openerp__.py
  4. 1
      mail_archives/models/__init__.py
  5. 27
      mail_archives/static/src/js/archives.js
  6. 19
      mail_base/static/src/js/base.js
  7. 12
      mail_sent/static/src/js/sent.js

4
mail_archives/README.rst

@ -1,11 +1,11 @@
Mail Archives
=============
Adds Archive menu, which shows all messages
Adds Archive menu, which shows sent/received messages
Usage
-----
Click Discuss/Archive menu -- all messages are displayed
Click Discuss/Archive menu -- sent/received messages are displayed
Further information
-------------------

2
mail_archives/__init__.py

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

4
mail_archives/__openerp__.py

@ -13,9 +13,7 @@
'currency': 'EUR',
"depends": [
"base",
"mail",
"mail_base"
"mail_base",
],
"data": [

1
mail_archives/models/__init__.py

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

27
mail_archives/static/src/js/archives.js

@ -16,6 +16,16 @@ 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){
@ -26,7 +36,17 @@ base_obj.MailTools.include({
set_channel_flags: function(data, msg){
this._super.apply(this, arguments);
msg.is_archive = true;
// 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;
},
@ -36,7 +56,10 @@ base_obj.MailTools.include({
},
get_domain: function(channel){
return (channel.id === "channel_archive") ? [] : this._super.apply(this, arguments);
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);
}
});

19
mail_base/static/src/js/base.js

@ -63,6 +63,11 @@ var channel_seen = _.throttle(function (channel) {
var ChatAction = core.action_registry.get('mail.chat.instant_messaging');
ChatAction.include({
init: function(parent, action, options) {
this._super.apply(this, arguments);
this.channels_show_send_button = ['channel_inbox'];
this.channels_display_subject = [];
},
start: function() {
var result = this._super.apply(this, arguments);
@ -93,6 +98,20 @@ ChatAction.include({
}
});
return result;
},
set_channel: function(channel){
var result = this._super.apply(this, arguments);
var self = this;
return $.when(result).done(function() {
self.$buttons
.find('.o_mail_chat_button_new_message')
.toggle(self.channels_show_send_button.indexOf(channel.id) != -1);
});
},
get_thread_rendering_options: function (messages) {
var options = this._super.apply(this, arguments);
options.display_subject = options.display_subject || this.channels_display_subject.indexOf(this.channel.id) != -1;
return options;
}
});

12
mail_sent/static/src/js/sent.js

@ -16,6 +16,18 @@ 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){

Loading…
Cancel
Save