[IMP]mail: js dataset, context

bzr revid: chm@openerp.com-20121015160324-tspchfwxg3v8nt2o
This commit is contained in:
Christophe Matthieu 2012-10-15 18:03:24 +02:00
parent 44646f0da0
commit f71d09a7db
3 changed files with 43 additions and 37 deletions

View File

@ -296,7 +296,8 @@ class mail_message(osv.Model):
'nb_messages': nb,
'type': 'expandable',
'parent_id': msg.id,
'id': id_min
'id': id_min,
'model': msg.model
})
id_min=None
id_max=None
@ -307,7 +308,8 @@ class mail_message(osv.Model):
'nb_messages': nb,
'type': 'expandable',
'parent_id': msg.id,
'id': id_min
'id': id_min,
'model': msg.model
})
for msg in tree+tree_not:
@ -348,6 +350,11 @@ class mail_message(osv.Model):
if context and context.get('message_loaded'):
domain += [ ['id','not in',message_loaded_ids] ];
print ""
print context
print domain
print ""
limit = limit or self._message_read_limit
context = context or {}

View File

@ -714,7 +714,7 @@ class mail_thread(osv.AbstractModel):
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])
added_message = self.pool.get('mail.message').message_read(cr, uid, [added_message_id], [['id','=',added_message_id]],context=context)
return added_message
def get_message_subtypes(self, cr, uid, ids, context=None):

View File

@ -349,7 +349,8 @@ openerp.mail = function(session) {
'comment',
false,
this.context.default_parent_id,
attachments]
attachments,
_.extend(this.parent_thread.context, {'message_loaded':[this.datasets.id||0].concat( self.parent_thread.options.thread._parents[0].get_child_ids() )})]
).then(function(records){
self.parent_thread.switch_new_message(records);
self.datasets.attachment_ids=[];
@ -386,6 +387,7 @@ openerp.mail = function(session) {
this.datasets = {};
this.datasets.id = options.parameters.id || -1;
this.datasets.model = options.parameters.model || false;
this.datasets.parent_id= options.parameters.parent_id || false;
this.datasets.nb_messages = options.parameters.nb_messages || 0;
this.datasets.type = 'expandable';
@ -471,29 +473,27 @@ openerp.mail = function(session) {
for(var i in param){
this[i] = param[i];
}
this.datasets = {};
this.datasets.id = param.id || -1;
this.datasets.model = param.model || false;
this.datasets.parent_id= param.parent_id || false;
this.datasets.res_id = param.res_id || false;
this.datasets.type = param.type || false;
this.datasets.is_author = param.is_author || false;
this.datasets.is_private = param.is_private || false;
this.datasets.subject = param.subject || false;
this.datasets.name = param.name || false;
this.datasets.record_name = param.record_name || false;
this.datasets.body = param.body || false;
this.datasets.vote_user_ids =param.vote_user_ids || [];
this.datasets.has_voted = param.has_voted || false;
this.datasets.has_stared = param.has_stared || false;
this.datasets.thread_level = param.thread_level || 0;
this.datasets.vote_user_ids = param.vote_user_ids || [];
this.datasets.unread = param.unread || false;
this.datasets = _.extend({
'id' : -1,
'model' : false,
'parent_id': false,
'res_id' : false,
'type' : false,
'is_author' : false,
'is_private' : false,
'subject' : false,
'name' : false,
'record_name' : false,
'body' : false,
'vote_user_ids' :[],
'has_voted' : false,
'has_stared' : false,
'thread_level' : 0,
'unread' : false,
'author_id' : [],
'attachment_ids' : [],
}, param || {});
this.datasets._date = param.date;
this.datasets.author_id = param.author_id || [];
this.datasets.attachment_ids = param.attachment_ids || [];
// record domain and context
this.domain = options.domain || [];
@ -890,7 +890,7 @@ openerp.mail = function(session) {
self.message_fetch();
});
this.$el.prepend(button_fetch);
this.$el.addClass("oe_mail_wall_first_thread");
this.$el.addClass("oe_mail_root_thread");
},
/* When the expandable object is visible on screen (with scrolling)
@ -1006,7 +1006,7 @@ openerp.mail = function(session) {
fetch_context = replace_context ? replace_context : this.context;
fetch_context.message_loaded= [this.datasets.id||0].concat( self.options.thread._parents[0].get_child_ids() );
return this.ds_message.call('message_read', [ids, fetch_domain, fetch_context, 0, this.context.default_parent_id || undefined]
return this.ds_message.call('message_read', [ids, fetch_domain, 0, fetch_context, this.context.default_parent_id || undefined]
).then(function (records) { self.switch_new_message(records); });
},
@ -1025,7 +1025,6 @@ openerp.mail = function(session) {
}
self.messages.push( self.insert_message(message) );
},
/** Displays a message or an expandable message */
@ -1038,9 +1037,9 @@ openerp.mail = function(session) {
var message = new mail.ThreadExpandable(self, {
'domain': record.domain,
'context': {
'default_model': record.model,
'default_res_id': record.res_id,
'default_parent_id': record.id },
'default_model': record.model || this.context.default_model,
'default_res_id': record.res_id || this.context.default_res_id,
'default_parent_id': self.datasets.id },
'parameters': record
});
} else {
@ -1064,13 +1063,13 @@ openerp.mail = function(session) {
// check older and newer message for insert
var parent_newer = false;
var parent_older = false;
if ( message.id > 0 ){
if ( message.datasets.id > 0 ){
for(var i in thread_messages){
if(thread_messages[i].id > message.id){
if(!parent_newer || parent_newer.id>=thread_messages[i].id)
if(thread_messages[i].datasets.id > message.datasets.id){
if(!parent_newer || parent_newer.datasets.id>=thread_messages[i].datasets.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<thread_messages[i].id)
} else if(thread_messages[i].datasets.id>0 && thread_messages[i].datasets.id < message.datasets.id) {
if(!parent_older || parent_older.id<thread_messages[i].datasets.id)
parent_older = thread_messages[i];
}
}