[FIX] calendar recurrent event, [IMP] duration instead of time end

This commit is contained in:
Fabien Pinckaers
2015-09-13 16:09:42 +02:00
parent d459ab1dfd
commit b7e393a71a
2 changed files with 23 additions and 11 deletions
+16 -5
View File
@@ -957,9 +957,7 @@ class calendar_event(osv.Model):
def _check_closing_date(self, cr, uid, ids, context=None):
for event in self.browse(cr, uid, ids, context=context):
if event.start_datetime and event.stop_datetime < event.start_datetime:
return False
if event.start_date and event.stop_date < event.start_date:
if event.stop < event.start:
return False
return True
@@ -1007,6 +1005,16 @@ class calendar_event(osv.Model):
return {'value': value}
def onchange_duration(self, cr, uid, ids, start=False, duration=False, context=None):
value = {}
if not (start and duration):
return value
start = datetime.strptime(start, DEFAULT_SERVER_DATETIME_FORMAT)
value['stop_date'] = (start + timedelta(hours=duration)).strftime(DEFAULT_SERVER_DATE_FORMAT)
value['stop_datetime'] = (start + timedelta(hours=duration)).strftime(DEFAULT_SERVER_DATETIME_FORMAT)
value['start_date'] = start.strftime(DEFAULT_SERVER_DATE_FORMAT)
return {'value': value}
def onchange_dates(self, cr, uid, ids, fromtype, start=False, end=False, checkallday=False, allday=False, context=None):
"""Returns duration and end date based on values passed
@@ -1749,8 +1757,11 @@ class mail_message(osv.Model):
convert the search on real ids in the case it was asked on virtual ids, then call super()
'''
for index in range(len(args)):
if args[index][0] == "res_id" and isinstance(args[index][2], basestring):
args[index][2] = get_real_ids(args[index][2])
if args[index][0] == "res_id":
if isinstance(args[index][2], basestring):
args[index][2] = get_real_ids(args[index][2])
elif isinstance(args[index][2], list):
args[index] = (args[index][0], args[index][1], map(lambda x: get_real_ids(x), args[index][2]))
return super(mail_message, self).search(cr, uid, args, offset=offset, limit=limit, order=order, context=context, count=count)
def _find_allowed_model_wise(self, cr, uid, doc_model, doc_dict, context=None):
+7 -6
View File
@@ -105,13 +105,14 @@
<field name="start_date" string="Starting at" on_change="onchange_dates('start', start_date, stop_date, allday, True)" attrs="{'invisible': [('allday','=',False)]}"/>
<field name="stop_date" string="Ending at" on_change="onchange_dates('stop', start_date, stop_date, allday, True)" attrs="{'invisible': [('allday','=',False)]}"/>
<field name="start_datetime" string="Starting at" on_change="onchange_dates('start', start_datetime, stop_datetime, allday, False)" attrs="{'invisible': [('allday','=',True)]}"/>
<field name="stop_datetime" string="Ending at" on_change="onchange_dates('stop', start_datetime, stop_datetime, allday, False)" attrs="{'invisible': [('allday','=',True)]}"/>
<label for="allday"/>
<div>
<field name="allday" class="oe_inline" on_change="onchange_allday(start, stop, start_date, stop_date, start_datetime, stop_datetime, allday)"/>
<field name="start_datetime" string="Starting at" on_change="onchange_duration(start_datetime, duration)" attrs="{'invisible': [('allday','=',True)]}"/>
<field name="stop_datetime" invisible="1"/>
<label for="duration" attrs="{'invisible': [('allday','=',True)]}"/>
<div attrs="{'invisible': [('allday','=',True)]}">
<field name="duration" widget="float_time" string="Duration" on_change="onchange_duration(start_datetime, duration)" class="oe_inline"/>
<span>hours</span>
</div>
<field name="duration" widget="float_time" class="oe_inline" attrs="{ 'invisible': True }"/>
<field name="allday" on_change="onchange_allday(start, stop, start_date, stop_date, start_datetime, stop_datetime, allday)"/>
</group>
<group>
<field name="categ_ids" widget="many2many_tags" />