summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Matthieu <chm@openerp.com>2012-09-27 19:23:17 +0200
committerChristophe Matthieu <chm@openerp.com>2012-09-27 19:23:17 +0200
commitd78a7cdea1a66ae319e68aa3fcfbf41b6ca48ccc (patch)
tree9749925dc4de2289d1272cbc38a2a207c9d0c119
parentc328ab9afe72ee58f921fd27ccc945dd6ba3f854 (diff)
[IMP]mail post: no send empty message
bzr revid: chm@openerp.com-20120927172317-2l19ef9jh0ttfgxy
-rw-r--r--addons/mail/static/src/js/mail.js10
-rw-r--r--addons/mail/wizard/mail_compose_message.py7
-rw-r--r--addons/mail/wizard/mail_compose_message_view.xml2
3 files changed, 15 insertions, 4 deletions
diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js
index e53bcc7c6bd..c7e14a2fb0a 100644
--- a/addons/mail/static/src/js/mail.js
+++ b/addons/mail/static/src/js/mail.js
@@ -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 */
diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py
index 32d361a3126..1ea8383eaea 100644
--- a/addons/mail/wizard/mail_compose_message.py
+++ b/addons/mail/wizard/mail_compose_message.py
@@ -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:
diff --git a/addons/mail/wizard/mail_compose_message_view.xml b/addons/mail/wizard/mail_compose_message_view.xml
index 2899c0c9a41..0f384dc5a0d 100644
--- a/addons/mail/wizard/mail_compose_message_view.xml
+++ b/addons/mail/wizard/mail_compose_message_view.xml
@@ -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'>