[IMP] mail: js, xml, Full reply; py read_message

bzr revid: chm@openerp.com-20121001175225-g27s6gtn2fmullgo
This commit is contained in:
Christophe Matthieu 2012-10-01 19:52:25 +02:00
parent 5edca09558
commit f0e4dfe42f
4 changed files with 33 additions and 31 deletions

View File

@ -305,12 +305,15 @@ class mail_message(osv.Model):
# don't read the message display by .js, in context message_loaded list
if context and context.get('message_loaded'):
domain += [['id','not in',context.get('message_loaded')]];
domain += [ ['id','not in',context.get('message_loaded')] ];
limit = limit or self._message_read_limit
context = context or {}
if not ids:
ids = self.search(cr, SUPERUSER_ID, domain, context=context, limit=limit)
# if the user can read a message, he can read all the thread
ids = ids + self.search(cr, SUPERUSER_ID, [['parent_id','in',ids]], None, limit=limit)
messages = self.browse(cr, uid, ids, context=context)
add_expandable = (len(messages) >= limit)
@ -473,9 +476,6 @@ class mail_message(osv.Model):
""" Add the related record followers to the destination partner_ids.
Call mail_notification.notify to manage the email sending
"""
print "notification ?"
message = self.browse(cr, uid, newid, context=context)
partners_to_notify = set([])
# message has no subtype_id: pure log message -> no partners, no one notified

View File

@ -351,7 +351,7 @@ openerp.mail = function(session) {
this.bind_events();
this.create_thread();
this.parent_thread.on_insert_message();
this.parent_thread.when_insert_message();
},
/**
@ -385,10 +385,7 @@ openerp.mail = function(session) {
event.stopPropagation();
var message=this.get_object_of_bind_event(event);
if(message){
if($(event.srcElement).hasClass("oe_full_reply")){
message.thread.instantiate_composition_form({'show_header_compose':true});
}
message.thread.$('div.oe_mail_thread_action:first').toggle();
message.thread.on_compose_message(true, false);
}
},
@ -396,18 +393,8 @@ openerp.mail = function(session) {
event.stopPropagation();
var message=this.get_object_of_bind_event(event);
if(message){
if($(event.srcElement).hasClass("oe_full_reply")){
message.thread.instantiate_composition_form({'show_header_compose':true});
}
if (!message.thread.compose_message_widget) return true;
message.thread.compose_message_widget.refresh({
'default_composition_mode': 'reply',
'default_parent_id': message.id,
'default_content_subtype': 'html'} );
message.thread.$('div.oe_mail_thread_action:first').toggle();
message.thread.on_compose_message(true, true);
}
},
expender: function(){
@ -456,11 +443,11 @@ openerp.mail = function(session) {
if(options.fadeTime) {
self.$el.fadeOut(options.fadeTime, function(){
self.destroy();
self.parent_thread.on_message_destroy();
self.parent_thread.when_message_destroy();
});
} else {
self.destroy();
self.parent_thread.on_message_destroy();
self.parent_thread.when_message_destroy();
}
for(var i in this.thread.messages){
@ -688,7 +675,6 @@ openerp.mail = function(session) {
* in the composition form. */
do_action: function(action, on_close) {
var self=this;
//self.$('.oe_mail_msg_content textarea').val("");
self.instantiate_composition_form();
self.message_fetch();
return this._super(action, on_close);
@ -712,7 +698,7 @@ openerp.mail = function(session) {
this.$el.on('click', 'a.oe_mail_fetch_more', this.do_message_fetch_more);
// event: writing in basic textarea of composition form (quick reply)
// event: onblur for hide 'Reply'
this.$('textarea.oe_mail_compose_textarea:first')
this.$('.oe_mail_compose_textarea:first textarea')
.keyup(function (event) {
var charCode = (event.which) ? event.which : window.event.keyCode;
if (event.shiftKey && charCode == 13) { this.value = this.value+"\n"; }
@ -736,13 +722,13 @@ openerp.mail = function(session) {
/* this method is call when we insert a message in the thread
* and object is create and started
*/
on_insert_message: function(){
when_insert_message: function(){
this.display_expandable();
},
/* this method is call when we destroy a message of the thread
*/
on_message_destroy: function(){
when_message_destroy: function(){
this.display_expandable();
},
@ -797,7 +783,6 @@ openerp.mail = function(session) {
* @param {boolean} show_header_compose, force to instantiate form
*/
instantiate_composition_form: function(context) {
// add message composition form view
if ((!context || !context.show_header_compose) &&
(!this.options.thread.show_header_compose || !this.options.thread.use_composer ||
@ -818,6 +803,22 @@ openerp.mail = function(session) {
}
},
/* this function is launch when a user click on "Reply" button
*/
on_compose_message: function(full_reply, by_mail){
if(full_reply){
this.instantiate_composition_form({'show_header_compose':true});
}
if(by_mail){
if (!this.compose_message_widget) return true;
this.compose_message_widget.refresh({
'default_composition_mode': 'reply',
'default_parent_id': message.id,
'default_content_subtype': 'html'} );
}
this.$('div.oe_mail_thread_action:first').toggle();
},
refresh: function (action_context) {
_(this.messages).each(function(){ this.destroy(); });
this.message_fetch();
@ -852,6 +853,8 @@ openerp.mail = function(session) {
message_fetch: function (initial_mode, additional_domain, additional_context) {
var self = this;
console.log("message_fetch", self);
// initial mode: try to use message_data or message_ids
if (initial_mode && this.options.thread.message_data) {
return this.create_message_object(this.options.message_data);
@ -988,7 +991,6 @@ openerp.mail = function(session) {
}
},
get_object_of_bind_event: function(event){
var source = $(event.srcElement).parents('[data-msg_id]:first');
var msg_id = source.data("msg_id");

View File

@ -62,12 +62,12 @@
for main thread composition form in document form view.
-->
<t t-name="mail.compose_message">
<div>
<div class="oe_mail_compose_textarea">
<img class="oe_mail_icon oe_mail_frame oe_left" alt="User img"/>
<div class="oe_mail_msg_content">
<!-- contains the composition form -->
<!-- default content: old basic textarea -->
<textarea class="oe_mail_compose_textarea" placeholder="Add your comment here..."/>
<textarea placeholder="Add your comment here..."/>
</div>
<div class="oe_clear"/>
</div>

View File

@ -257,7 +257,7 @@ class mail_compose_message(osv.TransientModel):
if context.get('mail_action_wizard_close'):
return {'type': 'ir.actions.act_window_close'}
else:
return False
return {}
def render_message(self, cr, uid, wizard, res_id, context=None):
""" Generate an email from the template for given (wizard.model, res_id)