[IMP]override name_search method and set _rec_name on subject in mail_mail
bzr revid: jpr@tinyerp.com-20140506104621-7gryl1gpv1hrmfvr
This commit is contained in:
parent
59a9d91558
commit
e8d8762c77
|
@ -136,14 +136,22 @@ class mail_alias(osv.Model):
|
|||
"""
|
||||
res = []
|
||||
for record in self.browse(cr, uid, ids, context=context):
|
||||
if record.alias_name and record.alias_domain:
|
||||
if record.alias_name or record.alias_domain:
|
||||
res.append((record['id'], "%s@%s" % (record.alias_name, record.alias_domain)))
|
||||
elif record.alias_name:
|
||||
res.append((record['id'], "%s" % (record.alias_name)))
|
||||
else:
|
||||
res.append((record['id'], _("New Alias")))
|
||||
res.append((record['id'], _("Inactive Alias")))
|
||||
return res
|
||||
|
||||
def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100):
|
||||
if not args:
|
||||
args = []
|
||||
ids = []
|
||||
if name:
|
||||
ids = self.search(cr, user, ['|',('alias_name', operator, name),('alias_domain', operator, name)] + args, limit=limit)
|
||||
else:
|
||||
ids = self.search(cr, user, args, context=context, limit=limit)
|
||||
return self.name_get(cr, user, ids, context=context)
|
||||
|
||||
def _find_unique(self, cr, uid, name, context=None):
|
||||
"""Find a unique alias name similar to ``name``. If ``name`` is
|
||||
already taken, make a variant by adding an integer suffix until
|
||||
|
|
|
@ -41,6 +41,7 @@ class mail_mail(osv.Model):
|
|||
_description = 'Outgoing Mails'
|
||||
_inherits = {'mail.message': 'mail_message_id'}
|
||||
_order = 'id desc'
|
||||
_rec_name = 'subject'
|
||||
|
||||
_columns = {
|
||||
'mail_message_id': fields.many2one('mail.message', 'Message', required=True, ondelete='cascade'),
|
||||
|
@ -68,9 +69,6 @@ class mail_mail(osv.Model):
|
|||
'state': 'outgoing',
|
||||
}
|
||||
|
||||
def name_get(self, cr, uid, ids, context=None):
|
||||
return [(mail["id"], "%s" % (mail['subject'] or _("New Mail"))) for mail in self.read(cr, uid, ids, ['subject'], context=context)]
|
||||
|
||||
def default_get(self, cr, uid, fields, context=None):
|
||||
# protection for `default_type` values leaking from menu action context (e.g. for invoices)
|
||||
# To remove when automatic context propagation is removed in web client
|
||||
|
|
Loading…
Reference in New Issue