From 317b4eeab78631162cfa72bff0dc751c37276e69 Mon Sep 17 00:00:00 2001 From: "rpa (Open ERP)" Date: Mon, 19 Apr 2010 19:17:20 +0530 Subject: [PATCH] [IMP]: base_calendar: Remaining changes for all day event, Added views and menus for Event and invitation bzr revid: rpa@tinyerp.com-20100419134720-xcjg2lrl0nt86r9u --- addons/base_calendar/base_calendar.py | 90 ++++++- addons/base_calendar/base_calendar_data.xml | 7 +- addons/base_calendar/base_calendar_view.xml | 261 ++++++++++++++++++-- 3 files changed, 325 insertions(+), 33 deletions(-) diff --git a/addons/base_calendar/base_calendar.py b/addons/base_calendar/base_calendar.py index 30bc83e0616..27c49d0b8d6 100644 --- a/addons/base_calendar/base_calendar.py +++ b/addons/base_calendar/base_calendar.py @@ -795,7 +795,26 @@ class calendar_event(osv.osv): def _tz_get(self, cr, uid, context={}): return [(x.lower(), x) for x in pytz.all_timezones] - def onchange_dates(self, cr, uid, ids, start_date, duration=False, end_date=False, context={}): + def onchange_allday(self, cr, uid, ids, allday, context={}): + """ + @param self: The object pointer + @param cr: the current row, from the database cursor, + @param uid: the current user’s ID for security checks, + @param ids: List of calendar event’s IDs. + @param allday: Value of allday boolean + @param context: A standard dictionary for contextual values + """ + if not allday or not ids: + return {} + event = self.browse(cr, uid, ids, context=context)[0] + value = { + 'date': event.date and event.date[:11] + '00:00:00', + 'date_deadline': event.date_deadline and event.date_deadline[:11] + '00:00:00', + 'duration': 24 + } + return {'value': value} + + def onchange_dates(self, cr, uid, ids, start_date, duration=False, end_date=False, allday=False, context={}): """ @param self: The object pointer @param cr: the current row, from the database cursor, @@ -805,14 +824,23 @@ class calendar_event(osv.osv): @param duration: Get Duration between start date and end date or False @param end_date: Get Ending Date or False @param context: A standard dictionary for contextual values - """ - if not start_date: - return {} value = {} + if not start_date: + return value if not end_date and not duration: duration = 8.00 - value['duration'] = 8.00 + value['duration'] = duration + + if allday: # For all day event + start = start_date[:11] + '00:00:00' + value = { + 'date': start, + 'date_deadline': start, + 'duration': 24 + } + return {'value': value} + start = datetime.strptime(start_date, "%Y-%m-%d %H:%M:%S") if end_date and not duration: end = datetime.strptime(end_date, "%Y-%m-%d %H:%M:%S") @@ -822,6 +850,7 @@ class calendar_event(osv.osv): elif not end_date: end = start + timedelta(hours=duration) value['date_deadline'] = end.strftime("%Y-%m-%d %H:%M:%S") + return {'value': value} def _set_rrulestring(self, cr, uid, id, name, value, arg, context): @@ -998,8 +1027,12 @@ e.g.: Every other month on the last Sunday of the month for 10 occurrences:\ ('3', 'Third'), ('4', 'Fourth'), \ ('5', 'Fifth'), ('-1', 'Last')], 'By day'), 'month_list': fields.selection(months.items(), 'Month'), - 'end_date': fields.date('Repeat Until') + 'end_date': fields.date('Repeat Until'), + 'attendee_ids': fields.many2many('calendar.attendee', 'event_attendee_rel',\ + 'event_id', 'attendee_id', 'Attendees'), + 'allday': fields.boolean('All Day') } + _defaults = { 'class': lambda *a: 'public', 'show_as': lambda *a: 'busy', @@ -1007,6 +1040,46 @@ e.g.: Every other month on the last Sunday of the month for 10 occurrences:\ 'select1': lambda *x: 'date', 'interval': lambda *x: 1, } + + def open_event(self, cr, uid, ids, context=None): + """ + Open Event From for Editing + @param cr: the current row, from the database cursor, + @param uid: the current user’s ID for security checks, + @param ids: List of event’s IDs + @param context: A standard dictionary for contextual values + @return: Dictionary value which open Crm Meeting form. + """ + if not context: + context = {} + + data_obj = self.pool.get('ir.model.data') + + value = {} + + id2 = data_obj._get_id(cr, uid, 'base_calendar', 'event_form_view') + id3 = data_obj._get_id(cr, uid, 'base_calendar', 'event_tree_view') + id4 = data_obj._get_id(cr, uid, 'base_calendar', 'event_calendar_view') + if id2: + id2 = data_obj.browse(cr, uid, id2, context=context).res_id + if id3: + id3 = data_obj.browse(cr, uid, id3, context=context).res_id + if id4: + id4 = data_obj.browse(cr, uid, id4, context=context).res_id + for id in ids: + value = { + 'name': _('Event'), + 'view_type': 'form', + 'view_mode': 'form,tree', + 'res_model': 'calendar.event', + 'view_id': False, + 'views': [(id2, 'form'), (id3, 'tree'), (id4, 'calendar')], + 'type': 'ir.actions.act_window', + 'res_id': base_calendar_id2real_id(id), + 'nodestroy': True + } + + return value def modify_this(self, cr, uid, event_id, defaults, real_date, context=None, *args): """ @@ -1085,8 +1158,8 @@ e.g.: Every other month on the last Sunday of the month for 10 occurrences:\ count = 0 for data in cr.dictfetchall(): - start_date = base_start_date and datetime.strptime(base_start_date, "%Y-%m-%d") or False - until_date = base_until_date and datetime.strptime(base_until_date, "%Y-%m-%d") or False + start_date = base_start_date and datetime.strptime(base_start_date[:10], "%Y-%m-%d") or False + until_date = base_until_date and datetime.strptime(base_until_date[:10], "%Y-%m-%d") or False if count > limit: break event_date = datetime.strptime(data['date'], "%Y-%m-%d %H:%M:%S") @@ -1261,7 +1334,6 @@ e.g.: Every other month on the last Sunday of the month for 10 occurrences:\ context.update({'alarm_id': vals.get('alarm_id')}) alarm_obj.do_alarm_create(cr, uid, new_ids, self._name, 'date', \ context=context) - return res def browse(self, cr, uid, ids, context=None, list_class=None, fields_process={}): diff --git a/addons/base_calendar/base_calendar_data.xml b/addons/base_calendar/base_calendar_data.xml index c8b20ac134b..a69a2f6cd9d 100755 --- a/addons/base_calendar/base_calendar_data.xml +++ b/addons/base_calendar/base_calendar_data.xml @@ -1,7 +1,12 @@ - + + + Event + calendar.event + + 1 minute before diff --git a/addons/base_calendar/base_calendar_view.xml b/addons/base_calendar/base_calendar_view.xml index c54693ef866..195e939908f 100755 --- a/addons/base_calendar/base_calendar_view.xml +++ b/addons/base_calendar/base_calendar_view.xml @@ -100,8 +100,31 @@ + + + + Event Invitations + ir.actions.act_window + calendar.attendee + form + tree,form + + {'default_sent_by_uid': uid} + + + + + + + + + - + res.alarm.form res.alarm form @@ -121,36 +144,228 @@ - - res.alarm.tree - res.alarm - tree - - - - - - - - - - - + + + + res.alarm.tree + res.alarm + tree + + + + + + + + + + + + + Available Alarms ir.actions.act_window res.alarm form tree,form - - - - + - - + + + + Event Form + calendar.event + form + +
+ + + + + + + + + + + +