[IMP] Calendar: invite attendnee, add origanizer detail into meetings

bzr revid: hmo@tinyerp.com-20100713111753-i5b2vc04cpye05wq
This commit is contained in:
Harry (OpenERP) 2010-07-13 16:47:53 +05:30
parent c145066710
commit 0c3569c69f
5 changed files with 121 additions and 97 deletions

View File

@ -419,10 +419,14 @@ property or property parameter."),
event.add('location').value = event_obj.location
if event_obj.rrule:
event.add('rrule').value = event_obj.rrule
if event_obj.user_id:
if event_obj.user_id or event_obj.organizer_id:
event_org = event.add('organizer')
event_org.params['CN'] = [event_obj.user_id.name]
event_org.value = 'MAILTO:' + (event_obj.user_id.user_email or event_obj.user_id.name)
organizer = event_obj.organizer_id
if not organizer:
organizer = event_obj.user_id
event_org.params['CN'] = [organizer.name]
event_org.value = 'MAILTO:' + (organizer.user_email or organizer.name)
if event_obj.alarm_id:
# computes alarm data
valarm = event.add('valarm')
@ -474,7 +478,7 @@ property or property parameter."),
sign = att.sent_by_uid and att.sent_by_uid.signature or ''
sign = '<br>'.join(sign and sign.split('\n') or [])
res_obj = att.ref
sub = '[%s Invitation][%d] %s' % (company, att.id, res_obj.name)
sub = res_obj.name
att_infos = []
other_invitaion_ids = self.search(cr, uid, [('ref', '=', res_obj._name + ',' + str(res_obj.id))])
for att2 in self.browse(cr, uid, other_invitaion_ids):
@ -546,13 +550,10 @@ property or property parameter."),
context = {}
for vals in self.browse(cr, uid, ids, context=context):
user = vals.user_id
if user:
if vals.ref and vals.ref.user_id:
mod_obj = self.pool.get(vals.ref._name)
if vals.ref:
if vals.ref.user_id.id != user.id:
defaults = {'user_id': user.id}
new_event = mod_obj.copy(cr, uid, vals.ref.id, default=defaults, context=context)
defaults = {'user_id': vals.user_id.id, 'organizer_id': vals.ref.user_id.id}
new_event = mod_obj.copy(cr, uid, vals.ref.id, default=defaults, context=context)
self.write(cr, uid, vals.id, {'state': 'accepted'}, context)
return True
@ -565,7 +566,8 @@ property or property parameter."),
@param ids: List of calendar attendees IDs
@param *args: Get Tupple value
@param context: A standard dictionary for contextual values """
if not context:
context = {}
return self.write(cr, uid, ids, {'state': 'declined'}, context)
def create(self, cr, uid, vals, context=None):
@ -585,7 +587,6 @@ property or property parameter."),
vals['cn'] = vals.get("cn")
res = super(calendar_attendee, self).create(cr, uid, vals, context)
return res
calendar_attendee()
class res_alarm(osv.osv):
@ -1110,6 +1111,7 @@ e.g.: Every other month on the last Sunday of the month for 10 occurrences:\
'vtimezone': fields.related('user_id', 'context_tz', type='char', size=24, \
string='Timezone', store=True),
'user_id': fields.many2one('res.users', 'Responsible', states={'done': [('readonly', True)]}),
'organizer_id': fields.many2one('res.users', 'Organizer', states={'done': [('readonly', True)]}),
'freq': fields.selection([('None', 'No Repeat'), \
('secondly', 'Secondly'), \
('minutely', 'Minutely'), \
@ -1154,7 +1156,9 @@ true, it will allow you to hide the event alarm information without removing it.
'select1': 'date',
'interval': 1,
'active': 1,
}
'user_id': lambda self, cr, uid, ctx: uid,
'organizer_id': lambda self, cr, uid, ctx: uid,
}
def open_event(self, cr, uid, ids, context=None):
"""
@ -1418,7 +1422,6 @@ true, it will allow you to hide the event alarm information without removing it.
until_date = arg[2]
res = super(calendar_event, self).search(cr, uid, args_without_date, \
offset, limit, order, context, count)
#Search Event ID which are invitted
return self.get_recurrent_ids(cr, uid, res, start_date, until_date, limit)

View File

@ -14,6 +14,11 @@
<field name="type">vevent</field>
</record>
<record model="basic.calendar.attributes" id="field_event_organizer">
<field name="name">organizer</field>
<field name="type">vevent</field>
</record>
<record model="basic.calendar.attributes" id="field_event_uid">
<field name="name">uid</field>
<field name="type">vevent</field>

View File

@ -228,6 +228,8 @@ class CalDAV(object):
att_data = []
for cal_data in child.getChildren():
if cal_data.name.lower() == 'organizer':
self.ical_set(cal_data.name.lower(), {'name':cal_data.params['CN']}, 'value')
if cal_data.name.lower() == 'attendee':
ctx = context.copy()
if cal_children:
@ -307,6 +309,13 @@ class CalDAV(object):
ical = tz_obj.export_cal(cr, uid, None, \
data[map_field], ical, context=context)
timezones.append(data[map_field])
elif field == 'organizer' and data[map_field]:
event_org = vevent.add('organizer')
organizer_id = data[map_field][0]
user_obj = self.pool.get('res.users')
organizer = user_obj.browse(cr, uid, organizer_id, context=context)
event_org.params['CN'] = [organizer.name]
event_org.value = 'MAILTO:' + (organizer.user_email or organizer.name)
elif data[map_field]:
if map_type in ("char", "text"):
if field in ('exdate'):
@ -528,7 +537,6 @@ class Calendar(CalDAV, osv.osv):
})
self.__attribute__ = get_attribute_mapping(cr, uid, child.name.lower(), context=context)
val = self.parse_ics(cr, uid, child, cal_children=cal_children, context=context)
val.update({'user_id': uid})
vals.append(val)
obj = self.pool.get(cal_children[child.name.lower()])
if hasattr(obj, 'check_import'):

View File

@ -107,6 +107,7 @@
<group col="2" colspan="2">
<separator colspan="2" string="Assignment"/>
<field name="user_id" />
<field name="organizer_id" groups="base.group_extended"/>
<field name="section_id" widget="selection"
groups="base.group_extended"/>
</group><group col="2" colspan="2">

View File

@ -29,6 +29,13 @@
<field name="object_id" search="[('model','=','calendar.attendee')]" />
</record>
<record model="basic.calendar.fields" id="map_event_0">
<field name="name" ref="caldav.field_event_organizer"/>
<field name="type_id" ref="base_calendar.calendar_lines_event" />
<field name="field_id" search="[('name','=','organizer_id'),('model_id.model','=','calendar.event')]" />
<field name="fn">field</field>
</record>
<record model="basic.calendar.fields" id="map_event_1">
<field name="name" ref="caldav.field_event_uid"/>
<field name="type_id" ref="base_calendar.calendar_lines_event" />