[IMP] mail: get free user attachment
bzr revid: chm@openerp.com-20121009084436-13r1hz3movoupvmh
This commit is contained in:
parent
7a41798d70
commit
52f8ea85c8
|
@ -343,6 +343,16 @@ class mail_message(osv.Model):
|
|||
|
||||
return result
|
||||
|
||||
def user_free_attachment(self, cr, uid, context=None):
|
||||
attachment_list = []
|
||||
|
||||
attachment = self.pool.get('ir.attachment')
|
||||
attachment_ids = attachment.search(cr, uid, [('res_model','=',''),('create_uid','=',uid)])
|
||||
if len(attachment_ids):
|
||||
attachment_list = [{'id': attach[0], 'name': attach[1]} for attach in attachment.name_get(cr, uid, attachment_ids, context=context)]
|
||||
|
||||
return attachment_list
|
||||
|
||||
#------------------------------------------------------
|
||||
# Email api
|
||||
#------------------------------------------------------
|
||||
|
|
|
@ -711,8 +711,7 @@ class mail_thread(osv.AbstractModel):
|
|||
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': [(6, 0, [pid for pid in attachment_ids])]} )
|
||||
|
||||
|
||||
|
||||
added_message = self.pool.get('mail.message').message_read(cr, uid, [added_message_id])
|
||||
return added_message
|
||||
|
||||
|
|
|
@ -164,6 +164,7 @@ openerp.mail = function(session) {
|
|||
session.web.blockUI();
|
||||
var form = self.$('form.oe_form_binary_form');
|
||||
form.submit();
|
||||
$target.after($target.clone(true)).remove();
|
||||
}
|
||||
},
|
||||
on_attachment_loaded: function (event, result) {
|
||||
|
@ -185,17 +186,27 @@ openerp.mail = function(session) {
|
|||
if (attachment_id) {
|
||||
var attachments=[];
|
||||
for(var i in this.attachment_ids){
|
||||
if(attachment_id!=this.attachment_ids[i].id)
|
||||
if(attachment_id!=this.attachment_ids[i].id){
|
||||
attachments.push(this.attachment_ids[i]);
|
||||
}
|
||||
else {
|
||||
var ds_attachment = new session.web.DataSetSearch(this, 'ir.attachment');
|
||||
ds_attachment.unlink([attachment_id]);
|
||||
}
|
||||
}
|
||||
this.attachment_ids = attachments;
|
||||
this.display_attachments();
|
||||
|
||||
var ds_attachment = new session.web.DataSetSearch(this, 'ir.attachment');
|
||||
ds_attachment.unlink([attachment_id]);
|
||||
}
|
||||
},
|
||||
|
||||
set_free_attachments: function(){
|
||||
var self=this;
|
||||
this.parent_thread.ds_message.call('user_free_attachment').then(function(attachments){
|
||||
self.attachment_ids=attachments;
|
||||
self.display_attachments();
|
||||
});
|
||||
},
|
||||
|
||||
bind_events: function() {
|
||||
var self = this;
|
||||
|
||||
|
@ -764,6 +775,7 @@ openerp.mail = function(session) {
|
|||
|
||||
if(this.options.thread.show_header_compose){
|
||||
this.ComposeMessage.$el.show();
|
||||
this.ComposeMessage.set_free_attachments();
|
||||
}
|
||||
|
||||
var button_flesh = $('<button style="display:none;" class="oe_mail_wall_button_fletch"/>').click(function(event){
|
||||
|
|
Loading…
Reference in New Issue