[FIX] stock: fixed views for stock.quant
[odoo/odoo.git] / addons / mail / res_partner.py
1 # -*- coding: utf-8 -*-
2 ##############################################################################
3 #
4 #    OpenERP, Open Source Management Solution
5 #    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
6 #
7 #    This program is free software: you can redistribute it and/or modify
8 #    it under the terms of the GNU Affero General Public License as
9 #    published by the Free Software Foundation, either version 3 of the
10 #    License, or (at your option) any later version.
11 #
12 #    This program is distributed in the hope that it will be useful,
13 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 #    GNU Affero General Public License for more details.
16 #
17 #    You should have received a copy of the GNU Affero General Public License
18 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 #
20 ##############################################################################
21
22 from openerp.tools.translate import _
23 from openerp.osv import fields, osv
24
25
26 class res_partner_mail(osv.Model):
27     """ Update partner to add a field about notification preferences """
28     _name = "res.partner"
29     _inherit = ['res.partner', 'mail.thread']
30     _mail_flat_thread = False
31
32     _columns = {
33         'notification_email_send': fields.selection([
34             ('none', 'Never'),
35             ('email', 'Incoming Emails only'),
36             ('comment', 'Incoming Emails and Discussions'),
37             ('all', 'All Messages (discussions, emails, followed system notifications)'),
38             ], 'Receive Messages by Email', required=True,
39             help="Policy to receive emails for new messages pushed to your personal Inbox:\n"
40                     "- Never: no emails are sent\n"
41                     "- Incoming Emails only: for messages received by the system via email\n"
42                     "- Incoming Emails and Discussions: for incoming emails along with internal discussions\n"
43                     "- All Messages: for every notification you receive in your Inbox"),
44     }
45
46     _defaults = {
47         'notification_email_send': lambda *args: 'comment'
48     }
49
50     def message_get_suggested_recipients(self, cr, uid, ids, context=None):
51         recipients = super(res_partner_mail, self).message_get_suggested_recipients(cr, uid, ids, context=context)
52         for partner in self.browse(cr, uid, ids, context=context):
53             self._message_add_suggested_recipient(cr, uid, recipients, partner, partner=partner, reason=_('Partner Profile'))
54         return recipients
55
56 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: