[MERGE] forward port of branch saas-2 up to revid 9151 chs@openerp.com-20140314104803-19c5snl2fcuih91o
bzr revid: chs@openerp.com-20140314105753-7a7wh9a1z99azgfj
This commit is contained in:
commit
b3bb47076b
|
@ -680,19 +680,23 @@ class calendar_event(osv.Model):
|
|||
return [d.astimezone(pytz.UTC) for d in rset1]
|
||||
|
||||
def _get_recurrency_end_date(self, data, context=None):
|
||||
if data.get('recurrency') and data.get('end_type') in ('count', unicode('count')):
|
||||
data_date_deadline = datetime.strptime(data.get('date_deadline'), '%Y-%m-%d %H:%M:%S')
|
||||
if data.get('rrule_type') in ('daily', unicode('count')):
|
||||
rel_date = relativedelta(days=data.get('count') + 1)
|
||||
elif data.get('rrule_type') in ('weekly', unicode('weekly')):
|
||||
rel_date = relativedelta(days=(data.get('count') + 1) * 7)
|
||||
elif data.get('rrule_type') in ('monthly', unicode('monthly')):
|
||||
rel_date = relativedelta(months=data.get('count') + 1)
|
||||
elif data.get('rrule_type') in ('yearly', unicode('yearly')):
|
||||
rel_date = relativedelta(years=data.get('count') + 1)
|
||||
end_date = data_date_deadline + rel_date
|
||||
else:
|
||||
end_date = data.get('end_date')
|
||||
if not data.get('recurrency'):
|
||||
return False
|
||||
|
||||
end_type = data.get('end_type')
|
||||
end_date = data.get('end_date')
|
||||
|
||||
if end_type == 'count' and all(data.get(key) for key in ['count', 'rrule_type', 'date_deadline']):
|
||||
count = data['count'] + 1
|
||||
delay, mult = {
|
||||
'daily': ('days', 1),
|
||||
'weekly': ('days', 7),
|
||||
'monthly': ('months', 1),
|
||||
'yearly': ('years', 1),
|
||||
}[data['rrule_type']]
|
||||
|
||||
deadline = datetime.strptime(data['date_deadline'], tools.DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
return deadline + relativedelta(**{delay: count * mult})
|
||||
return end_date
|
||||
|
||||
def _find_my_attendee(self, cr, uid, meeting_ids, context=None):
|
||||
|
@ -1427,7 +1431,7 @@ class calendar_event(osv.Model):
|
|||
# set end_date for calendar searching
|
||||
if values.get('recurrency', True) and values.get('end_type', 'count') in ('count', unicode('count')) and \
|
||||
(values.get('rrule_type') or values.get('count') or values.get('date') or values.get('date_deadline')):
|
||||
for data in self.read(cr, uid, ids, ['date', 'date_deadline', 'recurrency', 'rrule_type', 'count', 'end_type'], context=context):
|
||||
for data in self.read(cr, uid, ids, ['end_date', 'date_deadline', 'recurrency', 'rrule_type', 'count', 'end_type'], context=context):
|
||||
end_date = self._get_recurrency_end_date(data, context=context)
|
||||
super(calendar_event, self).write(cr, uid, [data['id']], {'end_date': end_date}, context=context)
|
||||
|
||||
|
@ -1458,11 +1462,12 @@ class calendar_event(osv.Model):
|
|||
if not 'user_id' in vals: # Else bug with quick_create when we are filter on an other user
|
||||
vals['user_id'] = uid
|
||||
|
||||
if vals.get('recurrency', True) and vals.get('end_type', 'count') in ('count', unicode('count')) and \
|
||||
(vals.get('rrule_type') or vals.get('count') or vals.get('date') or vals.get('date_deadline')):
|
||||
vals['end_date'] = self._get_recurrency_end_date(vals, context=context)
|
||||
|
||||
res = super(calendar_event, self).create(cr, uid, vals, context=context)
|
||||
|
||||
data = self.read(cr, uid, [res], ['end_date', 'date_deadline', 'recurrency', 'rrule_type', 'count', 'end_type'], context=context)[0]
|
||||
end_date = self._get_recurrency_end_date(data, context=context)
|
||||
self.write(cr, uid, [res], {'end_date': end_date}, context=context)
|
||||
|
||||
self.create_attendees(cr, uid, [res], context=context)
|
||||
return res
|
||||
|
||||
|
|
|
@ -160,6 +160,7 @@ class mail_thread(osv.AbstractModel):
|
|||
if res[id]['message_unread_count']:
|
||||
title = res[id]['message_unread_count'] > 1 and _("You have %d unread messages") % res[id]['message_unread_count'] or _("You have one unread message")
|
||||
res[id]['message_summary'] = "<span class='oe_kanban_mail_new' title='%s'><span class='oe_e'>9</span> %d %s</span>" % (title, res[id].pop('message_unread_count'), _("New"))
|
||||
res[id].pop('message_unread_count', None)
|
||||
return res
|
||||
|
||||
def read_followers_data(self, cr, uid, follower_ids, context=None):
|
||||
|
|
Loading…
Reference in New Issue