I have to create a calendar event through button function.
meeting_start_val = datetime.strptime(str_start_time, '%Y-%m-%d %H:%M:%S')
meeting_start = meeting_start_val.strftime("%Y-%m-%d %H:%M:%S")
meeting_end_val = meeting_start_val + timedelta(minutes=60)
meeting_end = meeting_end_val.strftime("%Y-%m-%d %H:%M:%S")
print "\n\n\n\n\nn\+++++++++++",meeting_end_val,type(meeting_end_val)
print "\n\n\n\n\nn\+++++++++++",meeting_start_val,type(meeting_start_val)
values = {
'name' : self.contact_name or '/',
'partner_ids' : [(6, 0, x)],
'allday' : False,
'start_datetime' : meeting_start_val,
'stop_datetime': meeting_end_val,
'description' : self.lead_id.name
}
print "\n\n\nn\n\n\n++++++++++++++++++values",values
event.create(cr, uid, values, context=context)
On executing the above code, I am getting on the print statement
1. print "\n\n\n\n\nn\+++++++++++",meeting_end_val,type(meeting_end_val)
Answer
n\+++++++++++ 2017-09-03 09:00:00 <type 'datetime.datetime'>
2. print "\n\n\n\n\nn\+++++++++++",meeting_start_val,type(meeting_start_val)
Answer
n\+++++++++++ 2017-09-03 08:00:00 <type 'datetime.datetime'>
3. print "\n\n\nn\n\n\n++++++++++++++++++values",values
Answer
++++++++++++++++++values {'start_datetime': datetime.datetime(2017, 9, 3, 8, 0), 'allday': False, 'description': u'SAC/M/08/17/011', 'stop_datetime': datetime.datetime(2017, 9, 3, 9, 0), 'partner_ids': [(6, 0, [2202, 172, 174, 169, 179, 175])], 'name': u'Child Name '}
I am facing this issue
TypeError: 'datetime.datetime' object has no attribute '__getitem__'
When I am passing as string , it doesnot get error but the time created in the caledar event is wrong.
Any help on this!
It worked by this..
10800 is seconds which is 3 hours, the difference between utc and KSA time. The reason was this conversion.
__getitem__ error was due to wrong sending of the values in datetime field.