From 25544c228911ffeaca2987c6b3d563c30e5d29b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 30 May 2013 14:41:28 +0200 Subject: [PATCH] [FIX] mail_alias: aliases proposed in empty list fixed. Check only aliases that effectively create new records (not aliases used for updating). When having several possible aliases, do not display any alias, because we do not have any information about the correct alias to display. bzr revid: tde@openerp.com-20130530124128-w7lz1jsrspyu38dv --- addons/mail/mail_thread.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 3103e4da298..6a32ed3bb52 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -101,12 +101,16 @@ class mail_thread(osv.AbstractModel): if catchall_domain and model and res_id: # specific res_id -> find its alias (i.e. section_id specified) object_id = self.pool.get(model).browse(cr, uid, res_id, context=context) - alias = object_id.alias_id + # check that the alias effectively creates new records + if object_id.alias_id and object_id.alias_id.alias_model_id and \ + object_id.alias_id.alias_model_id.model == self._name and \ + object_id.alias_id.alias_force_thread_id == 0: + alias = object_id.alias_id elif catchall_domain and model: # no specific res_id given -> generic help message, take an example alias (i.e. alias of some section_id) model_id = self.pool.get('ir.model').search(cr, uid, [("model", "=", self._name)], context=context)[0] alias_obj = self.pool.get('mail.alias') - alias_ids = alias_obj.search(cr, uid, [("alias_model_id", "=", model_id)], context=context, limit=1, order='id ASC') - if alias_ids: + alias_ids = alias_obj.search(cr, uid, [("alias_model_id", "=", model_id), ('alias_force_thread_id', '=', 0)], context=context, order='id ASC') + if alias_ids and len(alias_ids) == 1: # if several aliases -> incoherent to propose one guessed from nowhere, therefore avoid if several aliases alias = alias_obj.browse(cr, uid, alias_ids[0], context=context) if alias: