2012-08-13 12:31:11 +00:00
-
2013-12-19 14:47:39 +00:00
In Order to test calendar, I will first create One Simple Event with real data
2010-04-20 12:58:48 +00:00
-
2014-01-15 09:38:05 +00:00
!record {model: calendar.event, id: calendar_event_technicalpresentation0}:
2010-04-20 12:58:48 +00:00
class : private
2014-05-05 15:42:46 +00:00
start : '2011-04-30 16:00:00'
stop : '2011-04-30 18:30:00'
2010-04-20 12:58:48 +00:00
description : The Technical Presentation will cover following topics:\n* Creating OpenERP
class\n* Views\n* Wizards\n* Workflows
duration : 2.5
location : OpenERP S.A.
name : Technical Presentation
2012-10-05 18:50:15 +00:00
-
2012-08-13 12:31:11 +00:00
Now I will set recurrence for this event to occur monday and friday of week
2010-04-20 12:58:48 +00:00
-
2014-01-15 09:38:05 +00:00
!python {model: calendar.event}: |
2014-05-05 15:42:46 +00:00
data = {'fr': 1, 'mo': 1, 'interval': 1, 'rrule_type': 'weekly', 'end_type': 'end_date', 'final_date': '2011-05-31 00:00:00', 'recurrency' : True}
2014-01-15 09:38:05 +00:00
self.write(cr, uid, [ref("calendar_event_technicalpresentation0")], data)
2012-08-13 12:31:11 +00:00
-
In order to check that recurrent events are views successfully in calendar view, I will open calendar view of events
2010-04-20 12:58:48 +00:00
-
2014-01-15 09:38:05 +00:00
!python {model: calendar.event}: |
2010-04-20 12:58:48 +00:00
self.fields_view_get(cr, uid, False, 'calendar', context)
2012-08-13 12:31:11 +00:00
-
In order to check that recurrent events are views successfully in calendar view, I will search for one of the recurrent event and count the number of events
2010-04-20 12:58:48 +00:00
-
2014-01-15 09:38:05 +00:00
!python {model: calendar.event}: |
2014-05-05 15:42:46 +00:00
ids = self.search(cr, uid, [('start', '>=', '2011-04-30 16:00:00'), ('start', '<=', '2011-05-31 00:00:00')], context={'virtual_id': True} )
2012-12-12 17:42:15 +00:00
assert len(ids) == 9, 'Wrong number of events found'
2013-12-18 11:04:18 +00:00
-
Now I move a virtual event, to see that a real event is well created and depending from the native recurrence
-
2014-01-15 09:38:05 +00:00
!python {model: calendar.event}: |
2014-05-05 15:42:46 +00:00
ids = self.search(cr, uid, [('start', '>=', '2011-04-30 16:00:00'), ('start', '<=', '2011-05-31 00:00:00')], context={'virtual_id': True} )
before = self.search(cr, uid, [('start', '>=', '2011-04-30 16:00:00'), ('start', '<=', '2011-05-31 00:00:00')], context={'virtual_id': False})
2014-02-18 17:15:08 +00:00
# We start by detach the event
newid = self._detach_one_event(cr, uid,ids[1])
self.write(cr, uid,[newid], {'name':'New Name','recurrency' : True}, context={'virtual_id': True})
2014-05-05 15:42:46 +00:00
after = self.search(cr, uid, [('start', '>=', '2011-04-30 16:00:00'), ('start', '<=', '2011-05-31 00:00:00')], context={'virtual_id': False})
2013-12-18 11:04:18 +00:00
assert len(after) == len(before)+1, 'Wrong number of events found, after to have moved a virtual event'
2014-02-18 17:15:08 +00:00
new_id = list(set(after)-set(before))[0]
2013-12-18 11:04:18 +00:00
new_event = self.browse(cr,uid,new_id,context=context)
2014-02-18 17:15:08 +00:00
assert new_event.recurrent_id == before[0], 'Recurrent_id not correctly passed to the new event'
2012-08-13 12:31:11 +00:00
-
Now I will make All day event and test it
2010-04-20 12:58:48 +00:00
-
2014-01-15 09:38:05 +00:00
!record {model: calendar.event, id: calendar_event_alldaytestevent0}:
2010-04-20 12:58:48 +00:00
allday : 1
class : confidential
2014-05-05 15:42:46 +00:00
start : '2011-04-30 00:00:00'
stop : '2011-04-30 00:00:00'
2010-04-20 12:58:48 +00:00
description : 'All day technical test '
location : School
name : All day test event
2012-08-13 12:31:11 +00:00
-
In order to check reminder I will first create reminder
2012-10-05 18:50:15 +00:00
-
2013-12-18 11:04:18 +00:00
!record {model: calendar.alarm, id: res_alarm_daybeforeeventstarts0}:
2010-04-20 12:58:48 +00:00
name : 1 Day before event starts
2013-12-18 11:04:18 +00:00
duration : 1
interval : days
type : notification
2012-08-13 12:31:11 +00:00
-
Now I will assign this reminder to all day event
2010-04-20 12:58:48 +00:00
-
2014-01-15 09:38:05 +00:00
!python {model: calendar.event}: |
self.write(cr, uid, [ref("calendar_event_alldaytestevent0")], {'alarm_ids': [(6,0,[ref("res_alarm_daybeforeeventstarts0")])]})
2014-03-13 15:37:57 +00:00
-
I create a recuring rule for my event
-
2014-03-13 17:54:27 +00:00
!record {model: calendar.event, id: calendar.event_sprintreview1}:
2014-03-13 15:37:57 +00:00
name : Begin of month meeting
2014-05-05 15:42:46 +00:00
start : !eval time.strftime('%Y-%m-%d 12:00:00')
stop : !eval time.strftime('%Y-%m-%d 18:00:00')
2014-03-13 15:37:57 +00:00
recurrency : true
rrule : FREQ=MONTHLY;INTERVAL=1;COUNT=12;BYDAY=1MO
-
I check that the attributes are set correctly
-
2014-03-13 17:54:27 +00:00
!assert {model: calendar.event, id: calendar.event_sprintreview1}:
2014-03-13 15:37:57 +00:00
- rrule_type == 'monthly'
- count == 12
2014-03-14 11:39:55 +00:00
- month_by == 'day'
2014-03-13 15:37:57 +00:00
- byday == '1'
- week_list == 'MO'