diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index e7288a46853..ba6d101541c 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -59,6 +59,12 @@ class mail_message(osv.Model): _message_record_name_length = 18 _message_read_more_limit = 1024 + def default_get(self, cr, uid, fields, context=None): + # protection for `default_type` values leaking from menu action context (e.g. for invoices) + if context and context.get('default_type') and context.get('default_type') not in self._columns['type'].selection: + context = dict(context, default_type=None) + return super(mail_message, self).default_get(cr, uid, fields, context=context) + def _shorten_name(self, name): if len(name) <= (self._message_record_name_length + 3): return name diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index 040b83e8f33..44bb4e9ae09 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -7,39 +7,6 @@ openerp.mail = function (session) { openerp_mail_followers(session, mail); // import mail_followers.js openerp_FieldMany2ManyTagsEmail(session); // import manyy2many_tags_email.js - /** - * ------------------------------------------------------------ - * FormView - * ------------------------------------------------------------ - * - * Override of formview do_action method, to catch all return action about - * mail.compose.message. The purpose is to bind 'Send by e-mail' buttons. - */ - - session.web.FormView = session.web.FormView.extend({ - do_action: function (action) { - if (action.res_model == 'mail.compose.message') { - /* hack for stop context propagation of wrong value - * delete this hack when a global method to clean context is create - */ - var context_keys = ['default_template_id', 'default_composition_mode', - 'default_use_template', 'default_partner_ids', 'default_model', - 'default_res_id', 'default_content_subtype', 'default_subject', - 'default_body', 'active_id', 'lang', 'bin_raw', 'tz', - 'active_model', 'edi_web_url_view', 'active_ids', - 'default_attachment_ids'] - for (var key in action.context) { - if (_.indexOf(context_keys, key) == -1) { - action.context[key] = null; - } - } - /* end hack */ - } - return this._super.apply(this, arguments); - }, - }); - - /** * ------------------------------------------------------------ * ChatterUtils