[IMP] mail: sort messages

bzr revid: chm@openerp.com-20121009140354-3ozec5q42ckcg16w
This commit is contained in:
Christophe Matthieu 2012-10-09 16:03:54 +02:00
parent 2e4a6953c4
commit 7df8ef5d37
3 changed files with 15 additions and 24 deletions

View File

@ -705,7 +705,7 @@ class mail_thread(osv.AbstractModel):
subtype=subtype, parent_id=parent_id, context=context)
attachment_ids=[]
if attachments and attachments[0]!=None:
if attachments:
ir_attachment = self.pool.get('ir.attachment')
attachment_ids = ir_attachment.search(cr, 1, [('res_model', '=', ""), ('res_id', '=', ""), ('user_id', '=', uid), ('id', 'in', attachments)], context=context)
if attachment_ids:

View File

@ -356,6 +356,7 @@ openerp.mail = function(session) {
this.parent_thread.ds_thread.call('message_post_api', [
this.context.default_res_id, body, false, 'comment', false, this.context.default_parent_id, attachments])
.then(this.parent_thread.proxy('switch_new_message'));
this.attachment_ids=[];
this.on_cancel();
return true;
}
@ -1034,38 +1035,30 @@ openerp.mail = function(session) {
});
}
var thread = self.options.thread.display_on_flat ? self.options.thread._parents[0] : this;
var thread_messages = (self.options.thread.display_on_flat ? self.options.thread._parents[0].messages : []).concat(self.messages);
var thread = (self.options.thread.display_on_flat ? self.options.thread._parents[0] : self);
// check older and newer message for insert
var parent_newer = false;
var parent_older = false;
for(var i in thread.messages){
if(thread.messages[i].id > message.id){
if(!parent_newer || parent_newer.id>=thread.messages[i].id)
parent_newer = thread.messages[i];
} else if(thread.messages[i].id>0 && thread.messages[i].id < message.id) {
if(!parent_older || parent_older.id<thread.messages[i].id)
parent_older = thread.messages[i];
for(var i in thread_messages){
if(thread_messages[i].id > message.id){
if(!parent_newer || parent_newer.id>=thread_messages[i].id)
parent_newer = thread_messages[i];
} else if(thread_messages[i].id>0 && thread_messages[i].id < message.id) {
if(!parent_older || parent_older.id<thread_messages[i].id)
parent_older = thread_messages[i];
}
}
if(parent_older){
if(self.options.thread.display_on_flat)
message.insertAfter(parent_older.$el);
else
message.insertBefore(parent_older.$el);
message.insertBefore(parent_older.$el);
}
else if(parent_newer){
if(self.options.thread.display_on_flat)
message.insertBefore(parent_newer.$el);
else
message.insertAfter(parent_newer.$el);
message.insertAfter(parent_newer.$el);
}
else {
if(self.options.thread.display_on_flat)
message.appendTo(thread.list_ul);
else
message.prependTo(thread.list_ul);
message.prependTo(thread.list_ul);
}
return message
},

View File

@ -194,7 +194,7 @@
<li t-if="!widget.options.thread.display_on_flat" title="Read" class="oe_read"><a class="oe_read oe_e">W</a></li>
<li t-if="!widget.options.thread.display_on_flat" title="Set back to unread" class="oe_unread"><a class="oe_unread oe_e">h</a></li>
<li title="Quick reply"><a class="oe_reply oe_e">)</a></li>
<t t-if="(widget.options.message.show_reply || widget.options.message.show_reply_by_email || (widget.is_author and widget.options.message.show_dd_delete) || widget.type == 'email')">
<t t-if="(widget.is_author and widget.options.message.show_dd_delete) || widget.type == 'email'">
<li>
<span class="oe_dropdown_toggle">
<a class="oe_e" title="More options">í</a>
@ -204,8 +204,6 @@
<li t-if="display['show_hide']">
<a href="#" class="oe_mail_msg_hide_type" t-attf-data-subtype='{widget.subtype}'>Hide '<t t-esc="widget.subtype"/>' for this document</a>
</li> -->
<li t-if="widget.options.message.show_reply" title="Reply"><a class="oe_reply oe_full_reply">Full reply</a></li>
<li t-if="widget.options.message.show_reply_by_email"><a class="oe_reply_by_email oe_full_reply" title="Reply by mail">Full reply by mail</a></li>
<li t-if="widget.type == 'email'"><a class="oe_mail_msg_details" t-attf-href="#model=mail.message&amp;id=#{widget.id}" >Details</a></li>
</ul>
</span>