Launchpad automatic translations update.
[odoo/odoo.git] / addons / base_calendar / wizard / calendar_event_edit_all.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
22 from osv import osv
23 from osv import fields
24
25 class calendar_event_edit_all(osv.osv_memory):
26
27     def _default_values(self, cr, uid, context=None):
28         """ Get Default value for Start Date
29         @param self: The object pointer
30         @param cr: the current row, from the database cursor,
31         @param uid: the current user’s ID for security checks,
32         @param context: A standard dictionary for contextual values
33         @Return: Get Default value for Start Date
34         """
35         context_id = context and context.get('active_id', False) or False
36         if context_id:
37             if context.get('date'):
38                 return context.get('date')
39             else:
40                 model = context.get('model', False)
41                 model_obj = self.pool.get(model)
42                 event = model_obj.read(cr, uid, context_id, ['name', 'location', 'alarm_id'])
43                 return event['date']
44
45     def _default_deadline(self, cr, uid, context=None):
46         """ Get Default value for End Date
47         @param self: The object pointer
48         @param cr: the current row, from the database cursor,
49         @param uid: the current user’s ID for security checks,
50         @param context: A standard dictionary for contextual values
51         @return: Get Default value for End Date
52         """
53
54         context_id = context and context.get('active_id', False) or False
55         if context_id:
56             if context.get('date_deadline'):
57                 return context.get('date_deadline')
58             else:
59                 model = context.get('model', False)
60                 model_obj = self.pool.get(model)
61                 event = model_obj.read(cr, uid, context_id, ['name', 'location', 'alarm_id'])
62                 return event['date_deadline']
63
64     def modify_this(self, cr, uid, ids, context=None):
65         """
66         Modify All event for Crm Meeting.
67         @param cr: the current row, from the database cursor,
68         @param uid: the current user’s ID for security checks,
69         @param ids: List of calendar event edit all’s IDs
70         @return: dictionary {}
71         """
72         if context is None:
73             context = {}
74
75         context_id = context and context.get('active_id', False) or False
76         if context_id:
77             for datas in self.read(cr, uid, ids):
78                 model = context.get('model', False)
79                 model_obj = self.pool.get(model)
80                 model_obj.modify_all(cr, uid, [context_id], datas, context=context)
81                 return {'type': 'ir.actions.act_window_close'}
82
83     _name = "calendar.event.edit.all"
84     _description = "Calendar Edit all event"
85     _columns = {
86         'name': fields.char('Title', size=64, required=True),
87         'date': fields.datetime('Start Date', required=True),
88         'date_deadline': fields.datetime('End Date', required=True),
89         'location': fields.char('Location', size=124),
90         'alarm_id': fields.many2one('res.alarm', 'Reminder'),
91     }
92     _defaults = {
93         'date': _default_values,
94         'date_deadline': _default_deadline
95     }
96 calendar_event_edit_all()
97
98 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: