Thibault Delavallée (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-fix-send-by-email-tde into 
lp:openobject-addons.

Requested reviews:
  OpenERP Core Team (openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-fix-send-by-email-tde/+merge/123703

Send by email: back to the good ol' wizard. Added and cleaned context passed to 
the wizard. Cleaned JS code about managing this action; now a context option 
redirect is required to override the wizard and use OpenChatter.
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-fix-send-by-email-tde/+merge/123703
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-fix-send-by-email-tde.
=== modified file 'email_template/wizard/mail_compose_message.py'
--- email_template/wizard/mail_compose_message.py	2012-09-05 15:56:26 +0000
+++ email_template/wizard/mail_compose_message.py	2012-09-11 09:59:31 +0000
@@ -51,9 +51,11 @@
             context = {}
         result = super(mail_compose_message, self).default_get(cr, uid, fields, context=context)
         result['template_id'] = context.get('default_template_id', context.get('mail.compose.template_id', False))
-        # force html when using templates
+        # pre-render the template if any
         if result.get('use_template'):
-            result['content_subtype'] = 'html'
+            onchange_res = self.onchange_use_template(cr, uid, [], result.get('use_template'), result.get('template_id'),
+                result.get('composition_mode'), result.get('model'), result.get('res_id'), context=context)
+            result.update(onchange_res['value'])
         return result
 
     _columns = {

=== modified file 'mail/static/src/js/mail.js'
--- mail/static/src/js/mail.js	2012-09-10 08:36:24 +0000
+++ mail/static/src/js/mail.js	2012-09-11 09:59:31 +0000
@@ -17,19 +17,15 @@
      */
 
     session.web.FormView = session.web.FormView.extend({
-        // TDE FIXME TODO: CHECK WITH NEW BRANCH
         do_action: function(action, on_close) {
             if (action.res_model == 'mail.compose.message' &&
+                action.context && action.context.redirect == true &&
                 this.fields && this.fields.message_ids &&
                 this.fields.message_ids.view.get("actual_mode") != 'create') {
-                // debug
-                console.groupCollapsed('FormView do_action on mail.compose.message');
-                console.log('message_ids field:', this.fields.message_ids);
-                console.groupEnd();
                 var record_thread = this.fields.message_ids;
                 var thread = record_thread.thread;
-                thread.instantiate_composition_form('comment', true, false, 0, action.context);
-                return false;
+                thread.refresh_composition_form(action.context);
+                return true;
             }
             else {
                 return this._super(action, on_close);
@@ -174,7 +170,7 @@
             this.ds_compose.context = _.extend(this.ds_compose.context, this.options.context);
             return this.ds_compose.call('default_get', [
                 ['subject', 'body_text', 'body', 'attachment_ids', 'partner_ids', 'composition_mode',
-                    'model', 'res_id', 'parent_id', 'content_subtype'],
+                    'use_template', 'template_id', 'model', 'res_id', 'parent_id', 'content_subtype'],
                 this.ds_compose.get_context(),
             ]).then( function (result) { self.form_view.on_processed_onchange({'value': result}, []); });
         },
@@ -365,6 +361,11 @@
             return compose_done;
         },
 
+        refresh_composition_form: function (context) {
+            if (! this.compose_message_widget) return;
+            return this.compose_message_widget.refresh(context);
+        },
+
         /** Clean the thread */
         message_clean: function() {
             this.$el.find('div.oe_mail_thread_display').empty();
@@ -548,7 +549,6 @@
             this.options.domain = this.options.domain || [];
             this.options.context = {'default_model': 'mail.thread', 'default_res_id': false};
             this.options.thread_level = this.options.thread_level || 0;
-            this.thread_list = [];
         },
 
         start: function() {
@@ -564,7 +564,7 @@
         },
 
         destroy: function() {
-            for (var i in this.thread_list) { this.thread_list[i].destroy(); }
+            if (this.thread) { this.thread.destroy(); }
             this._super.apply(this, arguments);
         },
 
@@ -581,13 +581,13 @@
                 default_model: this.view.model });
             // create and render Thread widget
             this.$el.find('div.oe_mail_recthread_main').empty();
-            for (var i in this.thread_list) { this.thread_list[i].destroy(); }
+            if (this.thread) { this.thread.destroy(); }
             var thread = new mail.Thread(self, {
                 'context': this.options.context,
                 'thread_level': this.options.thread_level, 'show_header_compose': true,
                 'message_ids': this.get_value(),
                 'show_delete': true, 'composer': true });
-            this.thread_list.push(thread);
+            this.thread = thread;
             return thread.appendTo(this.$el.find('div.oe_mail_recthread_main'));
         },
     });

=== modified file 'sale/sale.py'
--- sale/sale.py	2012-08-31 07:40:32 +0000
+++ sale/sale.py	2012-09-11 09:59:31 +0000
@@ -769,13 +769,18 @@
         template_id = template and template[1] or False
         res = mod_obj.get_object_reference(cr, uid, 'mail', 'email_compose_message_wizard_form')
         res_id = res and res[1] or False
-        ctx = dict(context, active_model='sale.order', active_id=ids[0])
-        ctx.update({'mail.compose.template_id': template_id})
+        ctx = dict(context)
+        ctx.update({
+            'default_model': 'sale.order',
+            'default_res_id': ids[0],
+            'default_use_template': True,
+            'default_template_id': template_id,
+            })
         return {
             'view_type': 'form',
             'view_mode': 'form',
             'res_model': 'mail.compose.message',
-            'views': [(res_id,'form')],
+            'views': [(res_id, 'form')],
             'view_id': res_id,
             'type': 'ir.actions.act_window',
             'target': 'new',

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to