[IMP]mail post: no send empty message

bzr revid: chm@openerp.com-20120927172317-2l19ef9jh0ttfgxy
This commit is contained in:
Christophe Matthieu
2012-09-27 19:23:17 +02:00
parent c328ab9afe
commit d78a7cdea1
3 changed files with 15 additions and 4 deletions
+7 -3
View File
@@ -685,6 +685,7 @@ openerp.mail = function(session) {
/* Display the message if if the msg_id don't exists.
* If the record have a parent, insert parent or inside parent */
message_treat_new_data: function(records) {
console.log(this, records);
var self=this;
_(records.reverse()).each(function (record) {
if(!self.browse_thread({'id':record.id, 'model':record.model})){
@@ -709,9 +710,12 @@ openerp.mail = function(session) {
var body = comment_node.val();
comment_node.val('');
}
return this.ds_thread.call('message_post_api', [
[this.context.default_res_id], body, false, 'comment', false, this.context.default_parent_id, undefined])
.then(this.proxy('message_treat_new_data'));
if(body.match(/\S+/))
return this.ds_thread.call('message_post_api', [
[this.context.default_res_id], body, false, 'comment', false, this.context.default_parent_id, undefined])
.then(this.proxy('message_treat_new_data'));
else
return false;
},
/** Action: 'shows more' to fetch new messages */
@@ -217,6 +217,10 @@ class mail_compose_message(osv.TransientModel):
def send_mail(self, cr, uid, ids, context=None):
""" Process the wizard content and proceed with sending the related
email(s), rendering any template patterns on the fly if needed. """
print ""
print "send_mail", ids, context
if context is None:
context = {}
active_ids = context.get('active_ids')
@@ -225,6 +229,9 @@ class mail_compose_message(osv.TransientModel):
mass_mail_mode = wizard.composition_mode == 'mass_mail'
active_model_pool = self.pool.get(wizard.model if wizard.model else 'mail.thread')
if wizard.body_text==False:
return False
# wizard works in batch mode: [res_id] or active_ids
res_ids = active_ids if mass_mail_mode and wizard.model and active_ids else [wizard.res_id]
for res_id in res_ids:
@@ -75,7 +75,7 @@
<div colspan="2" class="oe_mail_compose_message_attachments"/>
<!-- buttons, with as few Chatter logic as possible -->
<div>
<button name="send_mail" string="Post" type="object"
<button name="send_mail" string="Post message" type="object"
class="oe_mail_compose_message_button_send"/>
</div>
<div class='oe_mail_compose_message_icons'>