[IMP] mail chatter: upload OK

bzr revid: chm@openerp.com-20121008152045-old4i0hjb5apmf0p
This commit is contained in:
Christophe Matthieu 2012-10-08 17:20:45 +02:00
parent 4557bf1d50
commit aff7e6d161
2 changed files with 37 additions and 27 deletions

View File

@ -701,19 +701,16 @@ class mail_thread(osv.AbstractModel):
user = self.pool.get('res.users').browse(cr, uid, uid, context=context) user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
thread_id = user.partner_id.id 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, 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=[] attachment_ids=[]
if attachments: if attachments and attachments[0]!=None:
ir_attachment = self.pool.get('ir.attachment') 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) attachment_ids = ir_attachment.search(cr, 1, [('res_model', '=', ""), ('res_id', '=', ""), ('user_id', '=', uid), ('id', 'in', attachments)], context=context)
if attachment_ids: 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('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]) added_message = self.pool.get('mail.message').message_read(cr, uid, [added_message_id])

View File

@ -104,6 +104,8 @@ openerp.mail = function(session) {
this.res_id = options.parameters.res_id; this.res_id = options.parameters.res_id;
this.is_private = options.parameters.is_private; this.is_private = options.parameters.is_private;
this.partner_ids = options.parameters.partner_ids; 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.attachment_ids = [];
this.show_attachment_delete = true; this.show_attachment_delete = true;
@ -229,7 +231,9 @@ openerp.mail = function(session) {
this.$('input[data-id]').remove(); this.$('input[data-id]').remove();
this.attachment_ids=[]; this.attachment_ids=[];
this.display_attachments(); 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*/ /*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.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')); .then(this.parent_thread.proxy('switch_new_message'));
this.on_cancel(); 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')); $(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 = $('<button style="display:none;" class="oe_mail_wall_button_fletch"/>').click(function(event){ var button_flesh = $('<button style="display:none;" class="oe_mail_wall_button_fletch"/>').click(function(event){
if(event)event.stopPropagation(); if(event)event.stopPropagation();
self.message_fletch(true); self.message_fletch(true);
}); });
this.$el.prepend(button_flesh); this.$el.prepend(button_flesh);
this.$el.addClass("oe_mail_wall_first_thread");
}, },
/* When the expandable object is visible on screen (with scrolling) /* When the expandable object is visible on screen (with scrolling)
@ -932,7 +940,7 @@ openerp.mail = function(session) {
var parent_older = false; var parent_older = false;
for(var i in thread.messages){ for(var i in thread.messages){
if(thread.messages[i].id > message.id){ 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]; parent_newer = thread.messages[i];
} else if(thread.messages[i].id>0 && thread.messages[i].id < message.id) { } else if(thread.messages[i].id>0 && thread.messages[i].id < message.id) {
if(!parent_older || parent_older.id<thread.messages[i].id) if(!parent_older || parent_older.id<thread.messages[i].id)
@ -940,13 +948,24 @@ openerp.mail = function(session) {
} }
} }
if(parent_older) if(parent_older){
message.insertBefore(parent_older.$el); if(self.options.thread.display_on_flat)
else if(parent_newer) message.insertAfter(parent_older.$el);
message.insertAfter(parent_newer.$el); else
else message.insertBefore(parent_older.$el);
message.prependTo(thread.list_ul); }
else if(parent_newer){
if(self.options.thread.display_on_flat)
message.insertBefore(parent_newer.$el);
else
message.insertAfter(parent_newer.$el);
}
else {
if(self.options.thread.display_on_flat)
message.appendTo(thread.list_ul);
else
message.prependTo(thread.list_ul);
}
return message return message
}, },
@ -1022,24 +1041,18 @@ openerp.mail = function(session) {
'options':{ 'options':{
'thread':{ 'thread':{
'thread_level': this.options.thread_level, 'thread_level': this.options.thread_level,
'show_header_compose': 0, //show_header_compose, 'show_header_compose': show_header_compose,
'use_composer': show_header_compose, 'use_composer': show_header_compose,
'display_on_flat':true 'display_on_flat':true
}, },
'message':{ 'message':{
'show_dd_delete': true, 'show_dd_delete': true
'show_reply_by_email': show_header_compose,
} }
}, },
'parameters': {}, 'parameters': {},
} }
); );
return this.thread.appendTo( this.$('.oe_mail_wall_threads:first') );
this.$('ul.oe_mail_wall_threads').empty();
var render_res = session.web.qweb.render('mail.wall_thread_container', {});
$(render_res).appendTo(this.$('ul.oe_mail_wall_threads'));
return this.thread.appendTo( this.$('li.oe_mail_wall_thread:last') );
}, },
}); });
@ -1128,7 +1141,7 @@ openerp.mail = function(session) {
'thread' :{ 'thread' :{
'thread_level': this.options.thread_level, 'thread_level': this.options.thread_level,
'use_composer': true, 'use_composer': true,
'show_header_compose': 0, 'show_header_compose': true,
}, },
'message': { 'message': {
'show_reply': this.options.thread_level > 0, 'show_reply': this.options.thread_level > 0,