diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py
index 40fe1c287c2..da4143df909 100644
--- a/addons/mail/mail_thread.py
+++ b/addons/mail/mail_thread.py
@@ -701,19 +701,16 @@ class mail_thread(osv.AbstractModel):
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
thread_id = user.partner_id.id
- if attachments and attachments[0]==None:
- attachments=[]
-
added_message_id = self.message_post(cr, uid, thread_id=thread_id, body=body, subject=subject, type=type,
- subtype=subtype, parent_id=parent_id, attachments=[], context=context)
+ subtype=subtype, parent_id=parent_id, context=context)
attachment_ids=[]
- if attachments:
+ if attachments and attachments[0]!=None:
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:
self.pool.get('ir.attachment').write(cr, 1, attachment_ids, { 'res_model': self._name, 'res_id': thread_id }, context=context)
- self.pool.get('mail.message').write(cr, 1, [added_message_id], {'attachment_ids': attachment_ids} )
+ self.pool.get('mail.message').write(cr, 1, [added_message_id], {'attachment_ids': [(6, 0, [pid for pid in attachment_ids])]} )
added_message = self.pool.get('mail.message').message_read(cr, uid, [added_message_id])
diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js
index bcfc6ba276c..599241e598f 100644
--- a/addons/mail/static/src/js/mail.js
+++ b/addons/mail/static/src/js/mail.js
@@ -104,6 +104,8 @@ openerp.mail = function(session) {
this.res_id = options.parameters.res_id;
this.is_private = options.parameters.is_private;
this.partner_ids = options.parameters.partner_ids;
+ this.show_header_compose = options.parameters.options.thread.show_header_compose;
+ this.display_on_flat = options.parameters.options.thread.display_on_flat;
this.attachment_ids = [];
this.show_attachment_delete = true;
@@ -229,7 +231,9 @@ openerp.mail = function(session) {
this.$('input[data-id]').remove();
this.attachment_ids=[];
this.display_attachments();
- this.$el.hide();
+ if(!this.show_header_compose || !this.display_on_flat){
+ this.$el.hide();
+ }
},
/*post a message and fletch the message*/
@@ -248,7 +252,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])
+ this.context.default_res_id, body, false, 'comment', false, this.context.default_parent_id, attachments])
.then(this.parent_thread.proxy('switch_new_message'));
this.on_cancel();
}
@@ -752,12 +756,16 @@ openerp.mail = function(session) {
$(session.web.qweb.render('mail.wall_no_message', {})).appendTo(this.$('ul.oe_mail_thread_display'));
+ if(this.options.thread.show_header_compose){
+ this.ComposeMessage.$el.show();
+ }
+
var button_flesh = $('').click(function(event){
if(event)event.stopPropagation();
self.message_fletch(true);
});
this.$el.prepend(button_flesh);
-
+ this.$el.addClass("oe_mail_wall_first_thread");
},
/* When the expandable object is visible on screen (with scrolling)
@@ -932,7 +940,7 @@ openerp.mail = function(session) {
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)
+ 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 0,