From 8f59e1d906d623a4ac62c788e5d5792a69becb4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Fri, 31 Aug 2012 13:52:02 +0200 Subject: [PATCH] [IMP] mail_notification: removed select on columns, added creation of a combined index in init. bzr revid: tde@openerp.com-20120831115202-q3fvj4tjoglaqw9c --- addons/mail/mail_followers.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/addons/mail/mail_followers.py b/addons/mail/mail_followers.py index 9be82d077c6..9646744fae8 100644 --- a/addons/mail/mail_followers.py +++ b/addons/mail/mail_followers.py @@ -57,16 +57,21 @@ class mail_notification(osv.Model): _columns = { 'partner_id': fields.many2one('res.partner', string='Contact', - ondelete='cascade', required=True, select=1), - 'read': fields.boolean('Read', select=1), + ondelete='cascade', required=True), + 'read': fields.boolean('Read'), 'message_id': fields.many2one('mail.message', string='Message', - ondelete='cascade', required=True, select=1), + ondelete='cascade', required=True), } _defaults = { 'read': False, } + def init(self, cr): + cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = %s', ('mail_notification_partner_id_read_message_id',)) + if not cr.fetchone(): + cr.execute('CREATE INDEX mail_notification_partner_id_read_message_id ON mail_notification (partner_id, read, message_id)') + def create(self, cr, uid, vals, context=None): """ Override of create to check that we can not create a notification for a message the user can not read. """