[IMP] mail: attachment res_model, read => to_read

bzr revid: chm@openerp.com-20121017093559-fndir3gssokoda7v
This commit is contained in:
Christophe Matthieu 2012-10-17 11:35:59 +02:00
parent 23e20e95d4
commit ec88647be0
5 changed files with 23 additions and 23 deletions

View File

@ -74,10 +74,11 @@ class mail_message(osv.Model):
notif_obj = self.pool.get('mail.notification')
notif_ids = notif_obj.search(cr, uid, [
('partner_id', 'in', [partner_id]),
('message_id', 'in', ids)
('message_id', 'in', ids),
('read', '=', True)
], context=context)
for notif in notif_obj.browse(cr, uid, notif_ids, context=context):
res[notif.message_id.id] = notif.read and 'read' or 'unread'
res[notif.message_id.id] = not notif.read
return res
def _search_read(self, cr, uid, obj, name, domain, context=None):
@ -126,7 +127,7 @@ class mail_message(osv.Model):
'date': fields.datetime('Date'),
'message_id': fields.char('Message-Id', help='Message unique identifier', select=1, readonly=1),
'body': fields.html('Contents', help='Automatically sanitized HTML contents'),
'read': fields.function(_get_read, fnct_search=_search_read,
'to_read': fields.function(_get_read, fnct_search=_search_read,
type='boolean', string='Read',
help='Functional field to search for read messages linked to uid'),
'subtype_id': fields.many2one('mail.message.subtype', 'Subtype'),
@ -139,7 +140,7 @@ class mail_message(osv.Model):
def _needaction_domain_get(self, cr, uid, context=None):
if self._needaction:
return [('read', '=', 'unread')]
return [('to_read', '=', True)]
return []
def _get_default_author(self, cr, uid, context=None):
@ -252,7 +253,7 @@ class mail_message(osv.Model):
'vote_user_ids': vote_ids,
'has_voted': has_voted,
'has_stared': has_stared,
'read': msg.read
'to_read': msg.to_read
}
def _message_read_expandable(self, cr, uid, tree, result, message_loaded_ids, domain, context, parent_id, limit):

View File

@ -685,7 +685,6 @@ class mail_thread(osv.AbstractModel):
values["is_private"] = msg.is_private or False
values["partner_ids"] = [(4, partner.id) for partner in msg.partner_ids] + [(4, msg.author_id.id)]
print values
# Avoid warnings about non-existing fields
for x in ('from', 'to', 'cc'):
values.pop(x, None)
@ -709,10 +708,10 @@ class mail_thread(osv.AbstractModel):
attachment_ids=[]
if attachments:
ir_attachment = self.pool.get('ir.attachment')
attachment_ids = ir_attachment.search(cr, 1, [('res_model', '=', False), ('res_id', '=', False), ('user_id', '=', uid), ('id', 'in', attachments)], context=context)
attachment_ids = ir_attachment.search(cr, SUPERUSER_ID, [('res_model', '=', 'mail.message'), ('res_id', '=', 0), ('create_uid', '=', 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': [(6, 0, [pid for pid in attachment_ids])]} )
self.pool.get('ir.attachment').write(cr, SUPERUSER_ID, attachment_ids, { 'res_model': self._name, 'res_id': thread_id }, context=context)
self.pool.get('mail.message').write(cr, SUPERUSER_ID, [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

View File

@ -16,7 +16,7 @@
</record>
<record id="action_mail_star_feeds" model="ir.actions.client">
<field name="name">Stared</field>
<field name="name">Favorites</field>
<field name="tag">mail.wall</field>
<field name="params" eval="&quot;{'domain': [('star_user_ids.user_ids', 'in', [uid])],
'context': {'default_model': 'res.partner', 'default_is_private': False, 'typeof_thread': 'stared'} }&quot;"/>
@ -61,7 +61,7 @@
<field name="parent_id" ref="mail.mail_feeds"/>
</record>
<record id="mail_starfeeds" model="ir.ui.menu">
<field name="name">Stared</field>
<field name="name">Favorites</field>
<field name="sequence" eval="14"/>
<field name="action" ref="action_mail_star_feeds"/>
<field name="parent_id" ref="mail.mail_feeds"/>

View File

@ -213,7 +213,7 @@ openerp.mail = function(session) {
on_attachment_loaded: function (event, result) {
//session.web.unblockUI();
for(var i in this.datasets.attachment_ids){
if(this.datasets.attachment_ids[i].filename == result.filename && this.datasets.attachment_ids[i].upload){
if(this.datasets.attachment_ids[i].filename == result.filename && this.datasets.attachment_ids[i].upload) {
this.datasets.attachment_ids[i]={
'id': result.id,
'name': result.name,
@ -503,7 +503,7 @@ openerp.mail = function(session) {
'has_voted' : false,
'has_stared' : false,
'thread_level' : 0,
'read' : false,
'to_read' : true,
'author_id' : [],
'attachment_ids' : [],
}, param || {});
@ -530,13 +530,13 @@ openerp.mail = function(session) {
}
};
this.datasets.show_reply = this.options.message.show_reply[0]<=0 &&
this.options.message.show_reply[0]>=this.datasets.thread_level &&
(this.options.message.show_reply[1]<0 || this.options.message.show_reply[1]<=this.datasets.thread_level);
this.datasets.show_reply = this.options.message.show_reply[0]>=0 &&
this.options.message.show_reply[0]<=this.datasets.thread_level &&
(this.options.message.show_reply[1]<0 || this.options.message.show_reply[1]>=this.datasets.thread_level);
this.datasets.show_read_unread = this.options.message.show_read_unread[0]<=0 &&
this.options.message.show_read_unread[0]>=this.datasets.thread_level &&
(this.options.message.show_read_unread[1]<0 || this.options.message.show_read_unread[1]<=this.datasets.thread_level);
this.datasets.show_read_unread = this.options.message.show_read_unread[0]>=0 &&
this.options.message.show_read_unread[0]<=this.datasets.thread_level &&
(this.options.message.show_read_unread[1]<0 || this.options.message.show_read_unread[1]>=this.datasets.thread_level);
// record options and data
this.parent_thread= parent.messages!= undefined ? parent : options.options.thread._parents[0];
@ -1363,7 +1363,7 @@ openerp.mail = function(session) {
},
'message': {
'show_reply': [0,0],
'show_read_unread': [0,0],
'show_read_unread': [0,-1],
'show_dd_delete': false,
},
},

View File

@ -42,7 +42,7 @@
<t t-call="HiddenInputFile">
<t t-set="fileupload_id" t-value="widget.fileupload_id"/>
<t t-set="fileupload_action">/web/binary/upload_attachment</t>
<input type="hidden" name="model" value=""/>
<input type="hidden" name="model" value="mail.message"/>
<input type="hidden" name="id" value="0"/>
<input type="hidden" name="session_id" t-att-value="widget.session.session_id"/>
</t>
@ -60,7 +60,7 @@
<li>
<span t-if="(attachment.upload or attachment.percent_loaded&lt;100)" t-attf-title="{(attachment.name || attachment.filename) + (attachment.date?' \n('+attachment.date+')':'' )}" t-attf-name="{attachment.name || attachment.filename}">
<div class="oe_upload_in_process">
<span>...wait upload...</span>
<span>...Upload in progress...</span>
</div>
<t t-raw="attachment.name || attachment.filename"/>
</span>
@ -180,7 +180,7 @@
</div>
<!-- default layout -->
<li t-name="mail.thread.message" t-attf-class="oe_mail oe_mail_thread_msg #{!widget.datasets.read ? 'oe_mail_undefined_read' : (widget.datasets.read=='read'?'oe_mail_read':'oe_mail_unread')}">
<li t-name="mail.thread.message" t-attf-class="oe_mail oe_mail_thread_msg #{widget.datasets.to_read ?'oe_mail_unread':'oe_mail_read'}">
<div t-attf-class="oe_msg_#{widget.datasets.type} oe_semantic_html_override">
<!-- message actions (read/unread, reply, delete...) -->
<ul class="oe_header">