[IMP] partner kanban, holidays, meeting
[odoo/odoo.git] / addons / base_calendar / crm_meeting.py
1 #  -*- coding: utf-8 -*-
2 ##############################################################################
3 #
4 #    OpenERP, Open Source Management Solution
5 #    Copyright (C) 2004-today OpenERP SA (<http://www.openerp.com>)
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 osv import osv, fields
23 import tools
24 from tools.translate import _
25
26 import base_calendar
27 from base_status.base_state import base_state
28
29 #
30 # crm.meeting is defined here so that it may be used by modules other than crm,
31 # without forcing the installation of crm.
32 #
33
34 class crm_meeting_type(osv.Model):
35     _name = 'crm.meeting.type'
36     _description = 'Meeting Type'
37     _columns = {
38         'name': fields.char('Name', size=64, required=True, translate=True),
39     }
40
41 class crm_meeting(base_state, osv.Model):
42     """ Model for CRM meetings """
43     _name = 'crm.meeting'
44     _description = "Meeting"
45     _order = "id desc"
46     _inherit = ["calendar.event", 'ir.needaction_mixin', "mail.thread"]
47     _columns = {
48         # base_state required fields
49         'create_date': fields.datetime('Creation Date', readonly=True),
50         'write_date': fields.datetime('Write Date', readonly=True),
51         'date_open': fields.datetime('Confirmed', readonly=True),
52         'date_closed': fields.datetime('Closed', readonly=True),
53         'partner_ids': fields.many2many('res.partner', 'crm_meeting_partner_rel', 'meeting_id','partner_id',
54             string='Attendees', states={'done': [('readonly', True)]}),
55         'state': fields.selection(
56                     [('draft', 'Unconfirmed'), ('open', 'Confirmed'), ('cancel', 'Cancelled'), ('done', 'Done')],
57                     string='Status', size=16, readonly=True),
58         # Meeting fields
59         'name': fields.char('Meeting Subject', size=128, required=True, states={'done': [('readonly', True)]}),
60         'categ_ids': fields.many2many('crm.meeting.type', 'meeting_category_rel',
61             'event_id', 'type_id', 'Tags'),
62         'attendee_ids': fields.many2many('calendar.attendee', 'meeting_attendee_rel',\
63                             'event_id', 'attendee_id', 'Attendees', states={'done': [('readonly', True)]}),
64     }
65     _defaults = {
66         'state': 'draft',
67     }
68
69     # ----------------------------------------
70     # OpenChatter
71     # ----------------------------------------
72
73     def case_get_note_msg_prefix(self, cr, uid, id, context=None):
74         return 'Meeting'
75
76     def case_open_send_note(self, cr, uid, ids, context=None):
77         return self.message_append_note(cr, uid, ids, body=_("Meeting has been <b>confirmed</b>."), context=context)
78
79     def case_close_send_note(self, cr, uid, ids, context=None):
80         return self.message_append_note(cr, uid, ids, body=_("Meeting has been <b>done</b>."), context=context)
81
82