[IMP] mail: split out the send method and define a new method for post-processing...
authorPurnendu Singh (OpenERP) <psi@tinyerp.com>
Tue, 27 Mar 2012 11:58:00 +0000 (17:28 +0530)
committerPurnendu Singh (OpenERP) <psi@tinyerp.com>
Tue, 27 Mar 2012 11:58:00 +0000 (17:28 +0530)
bzr revid: psi@tinyerp.com-20120327115800-mjcwrzz31sjytld0

addons/mail/mail_message.py
addons/mail/wizard/mail_compose_message.py
addons/mail/wizard/mail_compose_message_view.xml

index f2565de..db67751 100644 (file)
@@ -464,6 +464,20 @@ class mail_message(osv.osv):
         msg['sub_type'] = msg['subtype'] or 'plain'
         return msg
 
+    def _postprocess_sent_message(self, cr, uid, message, context=None):
+        """
+        if message is set to auto_delete=True then delete that sent messages as well as attachments
+
+        :param message: the message to parse
+        """
+        if message.auto_delete:
+            self.pool.get('ir.attachment').unlink(cr, uid,
+                                                  [x.id for x in message.attachment_ids \
+                                                        if x.res_model == self._name and \
+                                                           x.res_id == message.id],
+                                                  context=context)
+            message.unlink()
+        return True
 
     def send(self, cr, uid, ids, auto_commit=False, context=None):
         """Sends the selected emails immediately, ignoring their current
@@ -521,18 +535,9 @@ class mail_message(osv.osv):
                     message.write({'state':'sent', 'message_id': res})
                 else:
                     message.write({'state':'exception'})
-                model_pool = self.pool.get(message.model)
-                if hasattr(model_pool, '_hook_message_sent'):
-                    model_pool._hook_message_sent(cr, uid, message.res_id, context=context)
-                # if auto_delete=True then delete that sent messages as well as attachments
                 message.refresh()
-                if message.state == 'sent' and message.auto_delete:
-                    self.pool.get('ir.attachment').unlink(cr, uid,
-                                                          [x.id for x in message.attachment_ids \
-                                                                if x.res_model == self._name and \
-                                                                   x.res_id == message.id],
-                                                          context=context)
-                    message.unlink()
+                if message.state == 'sent':
+                    self._postprocess_sent_message(cr, uid, message, context=context)
             except Exception:
                 _logger.exception('failed sending mail.message %s', message.id)
                 message.write({'state':'exception'})
index 4f1163c..f82132a 100644 (file)
@@ -100,7 +100,6 @@ class mail_compose_message(osv.osv_memory):
         if not result.get('email_from'):
             current_user = self.pool.get('res.users').browse(cr, uid, uid, context)
             result['email_from'] = current_user.user_email or False
-        result['subtype'] = 'html'
         return result
 
     _columns = {
@@ -161,7 +160,6 @@ class mail_compose_message(osv.osv_memory):
             result.update({
                     'subtype' : message_data.subtype or 'plain', # default to the text version due to quoting
                     'body_text' : body,
-                    'body_html' : message_data.body_html,
                     'subject' : subject,
                     'attachment_ids' : [],
                     'model' : message_data.model or False,
index 3a44b04..d559d67 100644 (file)
@@ -23,7 +23,6 @@
                     <notebook colspan="4">
                         <page string="Body">
                             <field name="body_text" colspan="4" nolabel="1" height="300" width="300"/>
-                            <field name="body_html" invisible="1"/>
                         </page>
                         <page string="Attachments">
                             <field name="attachment_ids" colspan="4" nolabel="1"/>