diff --git a/addons/base_calendar/base_calendar.py b/addons/base_calendar/base_calendar.py index 0337cf210bf..cdb24f3a3ba 100644 --- a/addons/base_calendar/base_calendar.py +++ b/addons/base_calendar/base_calendar.py @@ -77,16 +77,6 @@ class calendar_attendee(osv.osv): _name = 'calendar.attendee' _description = 'Attendee information' -# def _get_address(self, name=None, email=None): -# """ -# Gives email information in ical CAL-ADDRESS type format. -# @param name: name for CAL-ADDRESS value -# @param email: email address for CAL-ADDRESS value -# """ -# if name and email: -# name += ':' -# return (name or '') + (email and ('MAILTO:' + email) or '') - def _compute_data(self, cr, uid, ids, name, arg, context=None): """ Compute data on function fields for attendee values. @@ -214,6 +204,66 @@ class calendar_attendee(osv.osv): """ res = False + mail_ids = [] + data_pool = self.pool.get('ir.model.data') + mailmess_pool = self.pool.get('mail.message') + mail_pool = self.pool.get('mail.mail') + template_pool = self.pool.get('email.template') + local_context = context.copy() + color = { + 'needsAction' : 'grey', + 'accepted' :'green', + 'tentative' :'#FFFF00', + 'declined':'red' + } + + if not isinstance(ids, (tuple, list)): + ids = [ids] + + for attendee in self.browse(cr, uid, ids, context=context): + dummy,template_id = data_pool.get_object_reference(cr, uid, 'base_calendar',template_xmlid) + dummy,act_id = data_pool.get_object_reference(cr, uid, 'base_calendar', "view_crm_meeting_calendar") + + if attendee.email and email_from: + ics_file = self.get_ics_file(cr, uid, attendee.event_id, context=context) + local_context['color'] = color + local_context['action_id'] = self.pool.get('ir.actions.act_window').search(cr, uid, [('view_id','=',act_id)], context=context)[0] + local_context['dbname'] = cr.dbname + local_context['base_url'] = self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url', default='http://localhost:8069', context=context) + mail_id = template_pool.send_mail(cr, uid, template_id, attendee.id, context=local_context) + + + vals = {} + if ics_file: + vals['attachment_ids'] = [(0,0,{'name': 'invitation.ics', + 'datas_fname': 'invitation.ics', + 'datas': str(ics_file).encode('base64')})] + vals['model'] = None #We don't want to have the mail in the tchatter while in queue! + the_mailmess = mail_pool.browse(cr,uid,mail_id,context=context).mail_message_id + mailmess_pool.write(cr,uid,[the_mailmess.id],vals,context=context) + mail_ids.append(mail_id) + + +# +# if not attendee.partner_id.opt_out: +# if 'partner_to' in vals: +# del vals['partner_to'] #hack between mail.mail and template.mail -> tde + + if mail_ids: + try: + res = mail_pool.send(cr, uid, mail_ids, context=context) + except Exception as e: + print e + + return res + + def ORI_send_mail_to_attendees(self, cr, uid, ids, email_from=tools.config.get('email_from', False), template_xmlid='crm_email_template_meeting_invitation', context=None): + """ + Send mail for event invitation to event attendees. + @param email_from: email address for user sending the mail + """ + res = False + mail_id = [] data_pool = self.pool.get('ir.model.data') mail_pool = self.pool.get('mail.mail') @@ -256,7 +306,7 @@ class calendar_attendee(osv.osv): if not attendee.partner_id.opt_out: if 'partner_to' in vals: del vals['partner_to'] #hack between mail.mail and template.mail -> tde - mail_id.append(mail_pool.create(cr, uid, vals, context=context)) + mail_id.append(mail_pool.create(cr, SUPERUSER_ID, vals, context=context)) if mail_id: @@ -1061,12 +1111,17 @@ class crm_meeting(osv.Model): if partner.id in attendees: continue access_token = self.new_invitation_token(cr, uid, event, partner.id) - att_id = self.pool.get('calendar.attendee').create(cr, uid, { + values = { 'partner_id': partner.id, 'event_id': event.id, 'access_token': access_token, 'email': partner.email, - }, context=context) + } + + if partner.id == current_user.partner_id.id: + values['state']='accepted' + + att_id = self.pool.get('calendar.attendee').create(cr, uid,values, context=context) # if partner.email: # mail_to = mail_to + " " + partner.email diff --git a/addons/base_calendar/base_calendar_data.xml b/addons/base_calendar/base_calendar_data.xml index 9edcc62fcbb..89de5b48787 100644 --- a/addons/base_calendar/base_calendar_data.xml +++ b/addons/base_calendar/base_calendar_data.xml @@ -118,49 +118,51 @@ crm.meeting - Meeting Invitation - ${object.user_id.email or ''} - ${object.name} - ${ctx['att_obj'].email} - - - + ${object.event_id.user_id.email or ''} + ${object.event_id.name} + + ${('' if object.partner_id and object.partner_id.email and object.partner_id.email==object.email else object.email|safe)} + ${object.partner_id and object.partner_id.email and object.partner_id.email==object.email and object.partner_id.id or False } + - ${object.name} + ${object.event_id.name} +
- ${object.name} + ${object.event_id.name}
- Hello ${ctx['att_obj'].cn} ,

${object.user_id.partner_id.name} invited you for the ${object.name} meeting of ${object.user_id.company_id.name}.

+ Hello ${object.cn} ,

${object.event_id.user_id.partner_id.name} invited you for the ${object.event_id.name} meeting of ${object.event_id.user_id.company_id.name}.

-
${object.get_interval(object.date, 'dayname')}
+
${object.event_id.get_interval(object.event_id.date, 'dayname')}
- ${object.get_interval(object.date,'day')} + ${object.event_id.get_interval(object.event_id.date,'day')}
-
${object.get_interval(object.date, 'month')}
-
${object.get_interval(object.date, 'time')}
+
${object.event_id.get_interval(object.event_id.date, 'month')}
+
${object.event_id.get_interval(object.event_id.date, 'time')}
- % if object.location: + % if object.event_id.location: - + % endif - % if object.description : + % if object.event_id.description : - % endif + % endif + % if not object.event_id.allday and object.event_id.duration: + + + + + % endif @@ -213,56 +229,65 @@
@@ -169,14 +171,14 @@
- : ${object.location} - (View Map) + : ${object.event_id.location} + (View Map)
@@ -185,11 +187,25 @@
- : ${object.description or ''} + : ${object.event_id.description}
+
+ Duration +
+
+
+ : ${('%dH%02d' % (object.event_id.duration,(object.event_id.duration*60)%60))} +
+
@@ -197,13 +213,13 @@
- :
- You - - % for attendee in object.attendee_ids: - % if attendee.cn != ctx['att_obj'].cn: -
- ${attendee.cn} + : + % for attendee in object.event_id.attendee_ids: +
+ % if attendee.cn != object.cn: + ${attendee.cn} + % else: + You % endif % endfor
-
- Accept - Decline -
-
-
Sent by ${object.user_id.name} from ${object.user_id.company_id.name}. View this meeting detail directly in OpenERP. -
+
+ Accept + Decline + View +
- ]]> + ]]> + - Meeting Invitation - ${object.user_id.email or ''} - ${object.name} - Date updated - ${ctx['att_obj'].email} - + Meeting Invitation + ${object.event_id.user_id.email or ''} + ${object.event_id.name} - Date has been updated + + ${('' if object.partner_id and object.partner_id.email and object.partner_id.email==object.email else object.email|safe)} + ${object.partner_id and object.partner_id.email and object.partner_id.email==object.email and object.partner_id.id or False } - - ${object.name} + ${object.event_id.name} +
- ${object.name} + ${object.event_id.name}
- Hello ${ctx['att_obj'].cn} ,
-

The date of the meeting has been changed...
The meeting created by ${object.user_id.partner_id.name} is now scheduled for : ${object.date}.

+ Hello ${object.cn} ,
+

The date of the meeting has been changed...
+ The meeting created by ${object.event_id.user_id.partner_id.name} is now scheduled for : ${object.event_id.date}.

-
${object.get_interval(object.date, 'dayname')}
+
${object.event_id.get_interval(object.event_id.date, 'dayname')}
- ${object.get_interval(object.date,'day')} + ${object.event_id.get_interval(object.event_id.date,'day')}
-
${object.get_interval(object.date, 'month')}
-
${object.get_interval(object.date, 'time')}
+
${object.event_id.get_interval(object.event_id.date, 'month')}
+
${object.event_id.get_interval(object.event_id.date, 'time')}
- % if object.location: + % if object.event_id.location: - + % endif - % if object.description : + % if object.event_id.description : - % endif + % endif + % if not object.event_id.allday and object.event_id.duration: + + + + + % endif @@ -315,55 +354,64 @@
@@ -271,14 +296,14 @@
- : ${object.location} - (View Map) + : ${object.event_id.location} + (View Map)
@@ -287,11 +312,25 @@
- : ${object.description or ''} + : ${object.event_id.description}
+
+ Duration +
+
+
+ : ${('%dH%02d' % (object.event_id.duration,(object.event_id.duration*60)%60))} +
+
@@ -299,13 +338,13 @@
- :
- You - - % for attendee in object.attendee_ids: - % if attendee.cn != ctx['att_obj'].cn: -
- ${attendee.cn} + : + % for attendee in object.event_id.attendee_ids: +
+ % if attendee.cn != object.cn: + ${attendee.cn} + % else: + You % endif % endfor
-
- Accept - Decline -
-
-
Sent by ${object.user_id.name} from ${object.user_id.company_id.name}. View this meeting detail directly in OpenERP. -
+
+ Accept + Decline + View +
- ]]> + ]]> + Meeting Invitation - ${object.user_id.email or ''} - ${object.name} - ${ctx['att_obj'].email} - + ${object.event_id.user_id.email or ''} + ${object.event_id.name} - Reminder + + ${('' if object.partner_id and object.partner_id.email and object.partner_id.email==object.email else object.email|safe)} + ${object.partner_id and object.partner_id.email and object.partner_id.email==object.email and object.partner_id.id or False } + - ${object.name} + ${object.event_id.name} +
- ${object.name} + ${object.event_id.name}
- Hello ${ctx['att_obj'].cn} ,

${object.user_id.partner_id.name} invited you for the ${object.name} meeting of ${object.user_id.company_id.name}.

+ Hello ${object.cn} ,
+

this it a rmeinder for the event below :

-
${object.get_interval(object.date, 'dayname')}
+
${object.event_id.get_interval(object.event_id.date, 'dayname')}
- ${object.get_interval(object.date,'day')} + ${object.event_id.get_interval(object.event_id.date,'day')}
-
${object.get_interval(object.date, 'month')}
-
${object.get_interval(object.date, 'time')}
+
${object.event_id.get_interval(object.event_id.date, 'month')}
+
${object.event_id.get_interval(object.event_id.date, 'time')}
- % if object.location: + % if object.event_id.location: - + % endif - % if object.description : + % if object.event_id.description : - % endif + % endif + % if not object.event_id.allday and object.event_id.duration: + + + + + % endif @@ -415,18 +477,13 @@
@@ -372,14 +420,14 @@
- : ${object.location} - (View Map) + : ${object.event_id.location} + (View Map)
@@ -388,11 +436,25 @@
- : ${object.description or ''} + : ${object.event_id.description}
+
+ Duration +
+
+
+ : ${('%dH%02d' % (object.event_id.duration,(object.event_id.duration*60)%60))} +
+
@@ -400,13 +462,13 @@
- :
- You - - % for attendee in object.attendee_ids: - % if attendee.cn != ctx['att_obj'].cn: -
- ${attendee.cn} + : + % for attendee in object.event_id.attendee_ids: +
+ % if attendee.cn != object.cn: + ${attendee.cn} + % else: + You % endif % endfor
- -
- Accept - Decline -
-
-
Sent by ${object.user_id.name} from ${object.user_id.company_id.name}. View this meeting detail directly in OpenERP. -
+ - ]]> + ]]> + + diff --git a/addons/google_calendar/res_config_view.xml b/addons/google_calendar/res_config_view.xml index eb66f350d56..41377c3ee57 100644 --- a/addons/google_calendar/res_config_view.xml +++ b/addons/google_calendar/res_config_view.xml @@ -87,7 +87,7 @@ --> - +