Browse Source

[PORT] mail_archivest to 11.0; mailgun installable: False

pull/125/head
ArtyomLosev 7 years ago
parent
commit
d7a13ecefa
No known key found for this signature in database GPG Key ID: 74CDB86A4E67B3E
  1. 2
      mail_archives/__openerp__.py
  2. 40
      mail_archives/static/src/js/archives.js
  3. 2
      mail_archives/static/src/xml/menu.xml
  4. 73
      mail_base/static/lib/base.js
  5. 1
      mailgun/__openerp__.py

2
mail_archives/__openerp__.py

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

40
mail_archives/static/src/js/archives.js

@ -1,14 +1,13 @@
odoo.define('mail_archives.archives', function (require) { odoo.define('mail_archives.archives', function (require) {
"use strict"; "use strict";
var base_obj = require('mail_base.base');
var chat_manager = require('mail_base.base').chat_manager;
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
var bus = require('bus.bus').bus; var bus = require('bus.bus').bus;
var config = require('web.config'); var config = require('web.config');
var core = require('web.core'); var core = require('web.core');
var data = require('web.data'); var data = require('web.data');
var Model = require('web.Model');
var session = require('web.session'); var session = require('web.session');
var time = require('web.time'); var time = require('web.time');
var web_client = require('web.web_client'); var web_client = require('web.web_client');
@ -33,15 +32,17 @@ ChatAction.include({
}); });
// Inherit class and override methods // Inherit class and override methods
base_obj.MailTools.include({
get_properties: function(msg){
var properties = this._super.apply(this, arguments);
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_archive = this.property_descr("channel_archive", msg, this); properties.is_archive = this.property_descr("channel_archive", msg, this);
return properties; return properties;
},
};
set_channel_flags: function(data, msg){
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 // Get recipients ids
var recipients_ids = []; var recipients_ids = [];
for (var i = 0; i < (data.partner_ids || []).length; i++){ for (var i = 0; i < (data.partner_ids || []).length; i++){
@ -54,32 +55,27 @@ base_obj.MailTools.include({
} }
return msg; return msg;
},
};
get_channel_array: function(msg){
var arr = 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_archive'); return arr.concat('channel_archive');
},
};
get_domain: function(channel){
chat_manager.get_domain = function(channel){
return (channel.id === "channel_archive") ? [ return (channel.id === "channel_archive") ? [
'|', ['partner_ids', 'in', [openerp.session.partner_id]], '|', ['partner_ids', 'in', [openerp.session.partner_id]],
['author_id.user_ids', 'in', [openerp.session.uid]] ['author_id.user_ids', 'in', [openerp.session.uid]]
] : this._super.apply(this, arguments);
] : chat_manager_super.get_domain.apply(this, arguments);
} }
});
base_obj.chat_manager.is_ready.then(function(){
// Add archive channel
base_obj.chat_manager.mail_tools.add_channel({
chat_manager.add_channel({
id: "channel_archive", id: "channel_archive",
name: _lt("Archive"), name: _lt("Archive"),
type: "static" type: "static"
}); });
return $.when();
});
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 --> <!--Inherit Sidebar and add Archive menu item after Starred -->
<t t-extend="mail.chat.Sidebar"> <t t-extend="mail.chat.Sidebar">
<t t-jquery="div[data-channel-id=channel_starred]" t-operation="after"> <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> <span class="o_channel_name mail_archives"> <i class="fa fa-archive"/> Archive </span>
</div> </div>
</t> </t>

73
mail_base/static/lib/base.js

@ -47,6 +47,79 @@ bus.on("window_focus", null, function() {
web_client.set_title_part("_chat"); web_client.set_title_part("_chat");
}); });
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);
var search_defaults = {};
var context = this.action ? this.action.context : [];
_.each(context, function (value, key) {
var match = /^search_default_(.*)$/.exec(key);
if (match) {
search_defaults[match[1]] = value;
}
});
this.searchview.defaults = search_defaults;
var self = this;
return $.when(result).done(function() {
$('.oe_leftbar').toggle(false);
self.searchview.do_search();
});
},
destroy: function() {
var result = this._super.apply(this, arguments);
$('.oe_leftbar .oe_secondary_menu').each(function(){
if ($(this).css('display') == 'block'){
if ($(this).children().length > 0) {
$('.oe_leftbar').toggle(true);
}
return false;
}
});
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;
},
update_message_on_current_channel: function(current_channel_id, message){
var starred = current_channel_id === "channel_starred" && !message.is_starred;
var inbox = current_channel_id === "channel_inbox" && !message.is_needaction;
return starred || inbox;
},
on_update_message: function (message) {
var self = this;
var current_channel_id = this.channel.id;
if (this.update_message_on_current_channel(current_channel_id, message)) {
chat_manager.get_messages({channel_id: this.channel.id, domain: this.domain}).then(function (messages) {
var options = self.get_thread_rendering_options(messages);
self.thread.remove_message_and_render(message.id, messages, options).then(function () {
self.update_button_status(messages.length === 0);
});
});
} else if (_.contains(message.channel_ids, current_channel_id)) {
this.fetch_and_render_thread();
}
}
});
chat_manager.notify_incoming_message = function (msg, options) { chat_manager.notify_incoming_message = function (msg, options) {
if (bus.is_odoo_focused() && options.is_displayed) { if (bus.is_odoo_focused() && options.is_displayed) {
// no need to notify // no need to notify

1
mailgun/__openerp__.py

@ -11,4 +11,5 @@
'data': [ 'data': [
'data/cron.xml', 'data/cron.xml',
], ],
'installable': False
} }
Loading…
Cancel
Save