diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index 4f12e528bdf..0eea12473ad 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -291,6 +291,21 @@ openerp.mail = function(session) { }); }, + /** + * Reinitialize the widget field values to the default values. The + * purpose is to avoid to destroy and re-build a form view. Default + * values are therefore given as for an onchange. */ + reinit: function() { + var self = this; + if (! this.form_view) return; + // debugger + var call_defer = this.ds_compose.call('default_get', [['subject', 'body_text', 'body_html', 'dest_partner_ids'], this.ds_compose.get_context()]).then( + function (result) { + self.form_view.on_processed_onchange({'value': result}, []); + }); + + }, + /** * Override-hack of do_action: clean the form */ do_action: function(action, on_close) { @@ -496,6 +511,8 @@ openerp.mail = function(session) { * in the composition form. */ do_action: function(action, on_close) { this.init_comments(); + if (this.compose_message_widget) { + this.compose_message_widget.reinit(); } return this._super(action, on_close); }, @@ -946,6 +963,8 @@ openerp.mail = function(session) { * in the composition form. */ do_action: function(action, on_close) { this.init_and_fetch_comments(); + if (this.compose_message_widget) { + this.compose_message_widget.reinit(); } return this._super(action, on_close); }, diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index b68d7d22040..5dbe52a957b 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -103,7 +103,6 @@ class mail_compose_message(osv.TransientModel): if not result.get('email_from'): current_user = self.pool.get('res.users').browse(cr, uid, uid, context=context) result['email_from'] = current_user.user_email or False - return result _columns = { @@ -137,7 +136,8 @@ class mail_compose_message(osv.TransientModel): 'model': model, 'res_id': res_id, 'email_from': user.user_email or tools.config.get('email_from', False), - 'body_html': '', + 'body_html': False, + 'body_text': False, }) return result