odoo/odoo — pull request #471 by rgo-odoo (2014-06-11 10:02:30+00:00)
Title: [FIX] mail: Speep improvement when sending email using 'Send by Email' w...

...izard. (Maintenance Case: 606994)

Related LP bug 1311087

This issue can be reproduced with the instance having millions of records for 'mail_message' and 'mail_message_subtype' tables(in my case, it's about 6 million records in each table in client's db).

The issue is, when we try to send an email from the model inheriting "mail.thread" using "Send by Email" wizard, it takes quite a time to complete the process. This is because two above mention tables are joined in the back-end to fetch the data due to the domain passed in _notify(...).

I have modified the domain(the fix is taken from the part of the commit http://bazaar.launchpad.net/~openerp/openobject-addons/trunk/revision/9345) and thus speed up this process.