diff --git a/addons/caldav/caldav.py b/addons/caldav/caldav.py
index 1e2aa15b77a..4bd0e496303 100644
--- a/addons/caldav/caldav.py
+++ b/addons/caldav/caldav.py
@@ -67,52 +67,106 @@ def _links_get(self, cr, uid, context={}):
return [(r['object'], r['name']) for r in res]
html_invitation = """
+
%(name)s
-
-
-
+
+
+
+ | Hello, |
+
+
+ | You are invited for OpenERP Event. |
+
+
+ | Below are the details of event : |
+
+
+
+
+
%(name)s
|
-
+
- |
- Start Date
+ |
+ Start Date
|
- %(start_date)s |
-
- End Date
+ | : %(start_date)s |
+
+ End Date
|
- %(end_date)s |
+ : %(end_date)s |
- | Description |
- %(description)s |
+ Description |
+ : %(description)s |
|
- Location
+ Location
|
- %(location)s |
+ : %(location)s |
|
- Event Attendees
+ Event Attendees
|
- %(attendees)s
+ : %(attendees)s
|
- """
+ Are you coming? |
+
+
+ -
+ YES
+
-
+ NO
+
-
+ MAYBE
+
+ |
+
+
+ |
+
+
+
+
+ | Note: If you are interested please reply this
+ mail and keep only your response from options YES, NO
+ and MAYBE. |
+
+
+ | From: |
+
+
+ | %(user)s |
+
+
+ | -------------------------- |
+
+
+ | %(sign)s |
+
+
+
+
+"""
class calendar_attendee(osv.osv):
_name = 'calendar.attendee'
@@ -253,6 +307,30 @@ request was delegated to"),
_defaults = {
'state': lambda *x: 'needs-action',
}
+
+ response_re = response_re = re.compile("Are you coming\?.*(YES|NO|MAYBE).*", re.UNICODE)
+
+ def msg_new(self, cr, uid, msg):
+ return False
+
+ def msg_act_get(self, msg):
+ mailgate_obj = self.pool.get('mail.gateway')
+ body = mailgate_obj.msg_body_get(msg)
+ actions = {}
+ res = self.response_re.findall(body['body'])
+ if res:
+ actions['state'] = res[0]
+ return actions
+
+ def msg_update(self, cr, uid, ids, msg, data={}, default_act='None'):
+ msg_actions = self.msg_act_get(msg)
+ if msg_actions.get('state'):
+ if msg_actions['state'] in ['YES', 'NO', 'MAYBE']:
+ mapping = {'YES': 'accepted', 'NO': 'declined', 'MAYBE': 'tentative'}
+ status = mapping[msg_actions['state']]
+ print 'Got response for invitation id: %s as %s' % (ids, status)
+ self.write(cr, uid, ids, {'state': status})
+ return True
def onchange_user_id(self, cr, uid, ids, user_id, *args, **argv):
if not user_id:
@@ -278,7 +356,7 @@ request was delegated to"),
vals['cn'] = vals.get("cn")
res = super(calendar_attendee, self).create(cr, uid, vals, context)
return res
-
+
calendar_attendee()
class res_alarm(osv.osv):
@@ -457,13 +535,13 @@ or contains the text to be used for display"""),
%s
""" % (alarm.name, alarm.trigger_date, alarm.description, \
- alarm.user_id.name, alarm.user_id.sign)
+ alarm.user_id.name, alarm.user_id.signature)
mail_to = [alarm.user_id.address_id.email]
for att in alarm.attendee_ids:
mail_to.append(att.user_id.address_id.email)
tools.email_send(
- tools.confirm['from_mail'],
+ tools.config.get('email_from',False),
mail_to,
sub,
body
@@ -1111,25 +1189,35 @@ class invite_attendee_wizard(osv.osv_memory):
elif type == 'external' and datas.get('email'):
vals.update({'email': datas['email']})
+ company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.name
+ att_infos = []
+ for att in res_obj.attendee_ids:
+ att_infos.append(((att.user_id and att.user_id.name) or \
+ (att.partner_id and att.partner_id.name) or \
+ att.email) + ' - Status: ' + att.state.title())
att_id = att_obj.create(cr, uid, vals)
obj.write(cr, uid, res_obj.id, {'attendee_ids': [(4, att_id)]})
-
- sub = '[OpenERP Invitation] %s' % (res_obj.name)
+ sign = res_obj.user_id and res_obj.user_id.signature or ''
+ sign = '
'.join(sign and sign.split('\n') or [])
+ sub = '[%s Invitation][%d] %s' % (company, att_id, res_obj.name)
body_vals = {'name': res_obj.name,
'start_date': res_obj.date,
'end_date': res_obj.date_deadline or None,
'description': res_obj.description,
'location': res_obj.location or '-',
- 'attendees': '-' #Todo
+ 'attendees': '
'.join(att_infos), #Todo
+ 'user': res_obj.user_id and res_obj.user_id.name or 'OpenERP User',
+ 'sign': sign
}
body = html_invitation % body_vals
mail_to = [datas['email']]
tools.email_send(
- res_obj.user_id.name,
+ tools.config.get('email_from',False),
mail_to,
sub,
body,
- subtype='html'
+ subtype='html',
+ reply_to=tools.config.get('email_from',False)
)
elif type == 'partner':
diff --git a/addons/caldav/caldav_view.xml b/addons/caldav/caldav_view.xml
index 4d10b9529f5..2d3a59892c7 100644
--- a/addons/caldav/caldav_view.xml
+++ b/addons/caldav/caldav_view.xml
@@ -95,21 +95,16 @@
-
-
+
+