[IMP] attachments display and accessibility in mail messages
a user can now download an attachment in one click bzr revid: abo@openerp.com-20120620140204-1mphi5tjyp57i74t
This commit is contained in:
@@ -423,7 +423,7 @@ class mail_thread(osv.osv):
|
||||
map_id_to_name[attach_id] = '' # use empty string as a placeholder
|
||||
|
||||
ids = map_id_to_name.keys()
|
||||
names = self.pool.get('ir.attachment').name_get(cr, uid, ids)
|
||||
names = self.pool.get('ir.attachment').name_get(cr, uid, ids, context=context)
|
||||
|
||||
# convert the list of tuples into a dictionnary
|
||||
for name in names:
|
||||
@@ -436,7 +436,6 @@ class mail_thread(osv.osv):
|
||||
for attach_id in msg["attachment_ids"]:
|
||||
msg["attachments"].append({'id': attach_id, 'name': map_id_to_name[attach_id]})
|
||||
|
||||
|
||||
""" Sort and return messages """
|
||||
msgs = sorted(msgs, key=lambda d: (-d['id']))
|
||||
return msgs
|
||||
|
||||
@@ -327,59 +327,59 @@
|
||||
|
||||
/* Gear menu */
|
||||
.openerp .oe_mail_msg_content a.oe_gear_menuaction {
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
right: 3px;
|
||||
display: none;
|
||||
color: #4c4c4c;
|
||||
cursor: pointer;
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
right: 3px;
|
||||
display: none;
|
||||
color: #4c4c4c;
|
||||
cursor: pointer;
|
||||
}
|
||||
.openerp .oe_mail_msg_content:hover .oe_gear_menuaction {
|
||||
display: block;
|
||||
display: block;
|
||||
}
|
||||
.openerp .oe_mail_msg_content a.oe_gear_menuaction:hover {
|
||||
text-decoration: none;
|
||||
text-decoration: none;
|
||||
}
|
||||
.openerp .oe_mail_msg_content ul.oe_gear_menu {
|
||||
list-style-type: none;
|
||||
display: none;
|
||||
position: absolute;
|
||||
top: 30px;
|
||||
right: -140px;
|
||||
padding: 4px;
|
||||
border: 1px solid #afafb6;
|
||||
min-width: 160px;
|
||||
overflow-x: hidden;
|
||||
z-index: 900;
|
||||
background: white;
|
||||
-moz-border-radius: 3px;
|
||||
-webkit-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
-moz-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
|
||||
-webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
|
||||
-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
|
||||
list-style-type: none;
|
||||
display: none;
|
||||
position: absolute;
|
||||
top: 30px;
|
||||
right: -140px;
|
||||
padding: 4px;
|
||||
border: 1px solid #afafb6;
|
||||
min-width: 160px;
|
||||
overflow-x: hidden;
|
||||
z-index: 900;
|
||||
background: white;
|
||||
-moz-border-radius: 3px;
|
||||
-webkit-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
-moz-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
|
||||
-webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
|
||||
-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
.openerp .oe_mail_msg_content ul.oe_gear_menu > li {
|
||||
float: none;
|
||||
}
|
||||
.openerp .oe_mail_msg_content .oe_gear_menu > li > a {
|
||||
display: block;
|
||||
padding: 3px 6px;
|
||||
line-height: 14px;
|
||||
color: #4c4c4c;
|
||||
text-decoration: none;
|
||||
display: block;
|
||||
padding: 3px 6px;
|
||||
line-height: 14px;
|
||||
color: #4c4c4c;
|
||||
text-decoration: none;
|
||||
}
|
||||
.openerp .oe_mail_msg_content .oe_gear_menu > li > a:hover {
|
||||
background: #f0f0fa;
|
||||
background: -moz-linear-gradient(#f0f0fa, #eeeef6);
|
||||
background: -webkit-gradient(linear, left top, left bottom, from(#f0f0fa), to(#eeeef6));
|
||||
background: -webkit-linear-gradient(#f0f0fa, #eeeef6);
|
||||
-moz-box-shadow: none;
|
||||
-webkit-box-shadow: none;
|
||||
-box-shadow: none;
|
||||
background: #f0f0fa;
|
||||
background: -moz-linear-gradient(#f0f0fa, #eeeef6);
|
||||
background: -webkit-gradient(linear, left top, left bottom, from(#f0f0fa), to(#eeeef6));
|
||||
background: -webkit-linear-gradient(#f0f0fa, #eeeef6);
|
||||
-moz-box-shadow: none;
|
||||
-webkit-box-shadow: none;
|
||||
-box-shadow: none;
|
||||
}
|
||||
.openerp .oe_mail_msg_content .oe_gear_menu p {
|
||||
margin-left: 12px;
|
||||
margin-left: 12px;
|
||||
}
|
||||
|
||||
/* Attachments */
|
||||
@@ -387,11 +387,15 @@
|
||||
display: none;
|
||||
width: 100%;
|
||||
border-top: 1px solid #CCC;
|
||||
margin-top: .5em;
|
||||
margin: .5em 0 0 0;
|
||||
padding: .5em 0;
|
||||
list-style-position: inside;
|
||||
}
|
||||
.openerp ul.oe_mail_msg_attachments li {
|
||||
float: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style-type: square;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -249,10 +249,21 @@ openerp.mail = function(session) {
|
||||
$.when(defer).then(function (records) {
|
||||
if (records.length <= self.params.limit) self.display.show_more = false;
|
||||
else { self.display.show_more = true; records.pop(); }
|
||||
|
||||
//build attachments download urls
|
||||
for (var k in records) {
|
||||
if (records[k].attachments) {
|
||||
for (var l in records[k].attachments) {
|
||||
records[k].attachments[l].url = self.session.origin + '/web/binary/saveas?session_id=' + self.session.session_id + '&model=ir.attachment&field=datas&filename_field=datas_fname&id='+records[k].attachments[l].id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.display_comments(records);
|
||||
if (self.display.show_more == true) self.$element.find('div.oe_mail_thread_more:last').show();
|
||||
else self.$element.find('div.oe_mail_thread_more:last').hide();
|
||||
});
|
||||
});
|
||||
|
||||
return defer;
|
||||
},
|
||||
|
||||
|
||||
@@ -202,7 +202,7 @@
|
||||
<ul class="oe_mail_msg_attachments">
|
||||
<t t-foreach="record.attachments" t-as="attachment">
|
||||
<li>
|
||||
<a href="#" data-res-model='ir.attachment' t-attf-data-res-id='{attachment.id}' class="oe_mail_internal_link">
|
||||
<a t-att-href="attachment.url">
|
||||
<t t-raw="attachment.name"/>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
Reference in New Issue
Block a user