[FIX] stock: put proper action in make picking button
[odoo/odoo.git] / addons / project_messages / messages.py
1 # -*- coding: utf-8 -*-
2 ##############################################################################
3 #
4 #    OpenERP, Open Source Management Solution
5 #    Copyright (C) 2004-2009 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 from osv import fields, osv
22 import netsvc
23
24 class messages(osv.osv):
25     """Message from one user to another within a project
26     """
27     _name = 'project.messages'
28     logger = netsvc.Logger()
29
30     _columns = {
31         'from_id':fields.many2one('res.users', 'From', ondelete="CASCADE"),
32         'to_id':fields.many2one('res.users', 'To', ondelete="CASCADE"),
33         'project_id':fields.many2one('project.project', 'Project',
34                                      required=True, ondelete="CASCADE"),
35         'message':fields.text('Message', required=True),
36     }
37
38     _defaults = {
39         'from_id':lambda self, cr, uid, context: uid,
40         'to_id':None,
41     }
42
43     def broadcast(self, cr, uid, project_id, message):
44         """ Send a message to all the users of a project.
45         The sender of the message is the current user.
46
47         The method returns the new message's id.
48
49         Arguments:
50         - `project_id`: the id of the project to broadcast to
51         - `message`: the message to broadcast
52         """
53         return self.create(cr, uid, {
54             'to_id':None,
55             'project_id':project_id,
56             'message':message
57         }, context=context)
58 messages()
59
60 class project_with_message(osv.osv):
61     _inherit = 'project.project'
62
63     _columns = {
64         'message_ids':fields.one2many(
65             'project.messages', 'project_id', 'Messages',
66             domain="[('to_id','in',[uid,False])]"),
67     }
68 project_with_message()