[FIX] mail: remove ugly hack for context filtering that wreaks havoc in contexts
This hacks makes a mess and works with a whitelist that completely breaks the generic context passing mechanism. Replaced by specific guard through default_get overrides for the models that are sensitive to default value leaks via context. E.g. mail.message is sensitive to leaked default_type context keys that are meant for other models, such as those passed by the Invoices menus. bzr revid: odo@openerp.com-20121121101917-izeu4c493un86udf
This commit is contained in:
parent
f3bc4f4f41
commit
fadd311945
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue