[IMP] calendar: add new char field for organizer in event and use it to map with Organizer attribute.

bzr revid: hmo@tinyerp.com-20100810123108-p870zh9vrbfl9644
This commit is contained in:
Harry (OpenERP) 2010-08-10 18:01:08 +05:30
parent d53b3d9c69
commit bcecd56c9e
5 changed files with 18 additions and 11 deletions

View File

@ -378,7 +378,6 @@ property or property parameter."),
}
_defaults = {
'state': 'needs-action',
'user_id': lambda self, cr, uid, ctx: uid,
'role': 'req-participant',
'rsvp': True,
'cutype': 'individual',
@ -419,7 +418,10 @@ 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 or event_obj.organizer_id:
if event_obj.organizer:
event_org.params['CN'] = [event_obj.organizer]
event_org.value = 'MAILTO:' + (event_obj.organizer)
elif event_obj.user_id or event_obj.organizer_id:
event_org = event.add('organizer')
organizer = event_obj.organizer_id
if not organizer:
@ -1111,6 +1113,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': fields.char("Organizer", size=256, states={'done': [('readonly', True)]}), # Map with Organizer Attribure of VEvent.
'organizer_id': fields.many2one('res.users', 'Organizer', states={'done': [('readonly', True)]}),
'freq': fields.selection([('None', 'No Repeat'), \
('secondly', 'Secondly'), \
@ -1147,6 +1150,11 @@ e.g.: Every other month on the last Sunday of the month for 10 occurrences:\
'active': fields.boolean('Active', help="If the active field is set to \
true, it will allow you to hide the event alarm information without removing it.")
}
def default_organizer(self, cr, uid, context=None):
user_pool = self.pool.get('res.users')
user = user_pool.browse(cr, uid, uid, context=context)
return user.user_email or user.name
_defaults = {
'state': 'tentative',
'class': 'public',
@ -1156,7 +1164,7 @@ true, it will allow you to hide the event alarm information without removing it.
'interval': 1,
'active': 1,
'user_id': lambda self, cr, uid, ctx: uid,
'organizer_id': lambda self, cr, uid, ctx: uid,
'organizer': default_organizer,
}
def open_event(self, cr, uid, ids, context=None):

View File

@ -10,6 +10,7 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Invite People">
<separator string="Invite People" colspan="4" />
<field name="type" />
<field name="send_mail" />
<newline />

View File

@ -235,7 +235,7 @@ class CalDAV(object):
exdates = []
for cal_data in child.getChildren():
if cal_data.name.lower() == 'organizer':
self.ical_set(cal_data.name.lower(), {'name': cal_data.params.get('CN') and cal_data.params.get('CN')[0]}, 'value')
self.ical_set(cal_data.name.lower(), cal_data.params.get('CN') and cal_data.params.get('CN')[0], 'value')
continue
if cal_data.name.lower() == 'attendee':
ctx = context.copy()
@ -334,12 +334,10 @@ class CalDAV(object):
exdates_updated.append(ex_date)
exfield.value = map(parser.parse, exdates_updated)
elif field == 'organizer' and data[map_field]:
organizer = 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)
event_org.params['CN'] = [organizer]
event_org.value = 'MAILTO:' + (organizer)
elif data[map_field]:
if map_type in ("char", "text"):
if field in ('exdate'):

View File

@ -107,7 +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="organizer" groups="base.group_extended"/>
<field name="section_id" widget="selection"
groups="base.group_extended"/>
</group><group col="2" colspan="2">

View File

@ -32,7 +32,7 @@
<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="field_id" search="[('name','=','organizer'),('model_id.model','=','calendar.event')]" />
<field name="fn">field</field>
</record>