|
|
@ -1,14 +1,13 @@ |
|
|
|
odoo.define('mail_archives.archives', function (require) { |
|
|
|
"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 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'); |
|
|
@ -33,53 +32,50 @@ ChatAction.include({ |
|
|
|
}); |
|
|
|
|
|
|
|
// 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; |
|
|
|
}, |
|
|
|
var chat_manager_super = _.clone(chat_manager); |
|
|
|
|
|
|
|
get_channel_array: function(msg){ |
|
|
|
var arr = this._super.apply(this, arguments); |
|
|
|
return arr.concat('channel_archive'); |
|
|
|
}, |
|
|
|
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); |
|
|
|
return properties; |
|
|
|
}; |
|
|
|
|
|
|
|
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); |
|
|
|
chat_manager.set_channel_flags = function (data, msg) { |
|
|
|
chat_manager_super.set_channel_flags.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]); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
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" |
|
|
|
}); |
|
|
|
// If author or recipient
|
|
|
|
if (data.author_id[0] === session.partner_id || recipients_ids.indexOf(session.partner_id) != -1) { |
|
|
|
msg.is_archive = true; |
|
|
|
} |
|
|
|
|
|
|
|
return $.when(); |
|
|
|
}); |
|
|
|
return msg; |
|
|
|
}; |
|
|
|
|
|
|
|
chat_manager.get_channel_array = function (msg) { |
|
|
|
var arr = chat_manager_super.get_channel_array.apply(this, arguments); |
|
|
|
return arr.concat('channel_archive'); |
|
|
|
}; |
|
|
|
|
|
|
|
chat_manager.get_domain = function(channel){ |
|
|
|
return (channel.id === "channel_archive") ? [ |
|
|
|
'|', ['partner_ids', 'in', [openerp.session.partner_id]], |
|
|
|
['author_id.user_ids', 'in', [openerp.session.uid]] |
|
|
|
] : chat_manager_super.get_domain.apply(this, arguments); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
chat_manager.add_channel({ |
|
|
|
id: "channel_archive", |
|
|
|
name: _lt("Archive"), |
|
|
|
type: "static" |
|
|
|
}); |
|
|
|
|
|
|
|
return base_obj.chat_manager; |
|
|
|
return chat_manager; |
|
|
|
|
|
|
|
}); |