diff --git a/addons/base_calendar/base_calendar.py b/addons/base_calendar/base_calendar.py index f4de02f7025..c216efa9f0e 100644 --- a/addons/base_calendar/base_calendar.py +++ b/addons/base_calendar/base_calendar.py @@ -19,7 +19,7 @@ # ############################################################################## -from datetime import datetime, timedelta +from datetime import datetime, timedelta, date from dateutil import parser from dateutil import rrule from osv import fields, osv @@ -36,7 +36,7 @@ months = { 10: "October", 11: "November", 12: "December" } -def get_recurrent_dates(rrulestring, exdate, startdate=None): +def get_recurrent_dates(rrulestring, exdate, startdate=None, exrule=None): """ Get recurrent dates based on Rule string considering exdate and start date @param rrulestring: Rulestring @@ -56,6 +56,8 @@ def get_recurrent_dates(rrulestring, exdate, startdate=None): for date in exdate: datetime_obj = todate(date) rset1._exdate.append(datetime_obj) + if exrule: + rset1.exrule(rrule.rrulestr(str(exrule), dtstart=startdate)) re_dates = map(lambda x:x.strftime('%Y-%m-%d %H:%M:%S'), rset1._iter()) return re_dates @@ -426,6 +428,72 @@ property or property parameter."), self.write(cr, uid, ids, {'state': status}) return True + def get_ics_file(self, cr, uid, event_obj, context=None): + """ + Returns iCalendar file for the event invitation + @param self: The object pointer + @param cr: the current row, from the database cursor, + @param uid: the current user’s ID for security checks, + @param event_obj: Event object (browse record) + @param context: A standard dictionary for contextual values + @return: .ics file content + """ + res = None + def ics_datetime(idate, short=False): + if short: + return date.fromtimestamp(time.mktime(time.strptime(idate, '%Y-%m-%d'))) + else: + return datetime.strptime(idate, '%Y-%m-%d %H:%M:%S') + try: + import vobject + except ImportError: + return res + cal = vobject.iCalendar() + event = cal.add('vevent') + event.add('created').value = ics_datetime(time.strftime('%Y-%m-%d %H:%M:%S')) + event.add('dtstart').value = ics_datetime(event_obj.date) + event.add('dtend').value = ics_datetime(event_obj.date_deadline) + event.add('summary').value = event_obj.name + if event_obj.description: + event.add('description').value = event_obj.description + if event_obj.location: + event.add('location').value = event_obj.location + if event_obj.rrule: + event.add('rrule').value = event_obj.rrule + + if event_obj.alarm_id: + # computes alarm data + valarm = event.add('valarm') + alarm_object = self.pool.get('res.alarm') + alarm_data = alarm_object.read(cr, uid, event_obj.alarm_id.id, context=context) + # Compute trigger data + interval = alarm_data['trigger_interval'] + occurs = alarm_data['trigger_occurs'] + duration = (occurs == 'after' and alarm_data['trigger_duration']) \ + or -(alarm_data['trigger_duration']) + related = alarm_data['trigger_related'] + trigger = valarm.add('TRIGGER') + trigger.params['related'] = [related.upper()] + if interval == 'days': + delta = timedelta(days=duration) + if interval == 'hours': + delta = timedelta(hours=duration) + if interval == 'minutes': + delta = timedelta(minutes=duration) + trigger.value = delta + + # Compute other details + valarm.add('DESCRIPTION').value = alarm_data['name'] or 'OpenERP' + + for attendee in event_obj.attendee_ids: + attendee_add = event.add('attendee') + attendee_add.params['CUTYPE'] = [str(attendee.cutype)] + attendee_add.params['ROLE'] = [str(attendee.role)] + attendee_add.params['RSVP'] = [str(attendee.rsvp)] + attendee_add.value = 'MAILTO:' + attendee.email + res = cal.serialize() + return res + def _send_mail(self, cr, uid, ids, mail_to, email_from=tools.config.get('email_from', False), context={}): """ Send mail for calendar attendee. @@ -443,7 +511,7 @@ property or property parameter."), res_obj = att.ref sub = '[%s Invitation][%d] %s' % (company, att.id, res_obj.name) att_infos = [] - other_invitaion_ids = self.search(cr, uid, [('ref', '=', att.ref._name + ',' + str(att.ref.id))]) + 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): att_infos.append(((att2.user_id and att2.user_id.name) or \ (att2.partner_id and att2.partner_id.name) or \ @@ -459,12 +527,14 @@ property or property parameter."), 'company': company } body = html_invitation % body_vals + attach = self.get_ics_file(cr, uid, res_obj, context=context) if mail_to and email_from: tools.email_send( email_from, mail_to, sub, body, + attach=attach and [('invitation.ics', attach)] or None, subtype='html', reply_to=email_from ) diff --git a/addons/thunderbird/installer.py b/addons/thunderbird/installer.py index 69576aa2a46..4e0f4435d31 100644 --- a/addons/thunderbird/installer.py +++ b/addons/thunderbird/installer.py @@ -39,15 +39,28 @@ class thunderbird_installer(osv.osv_memory): self.write(cr, uid, ids, data) return False + def process_pdf_file(self, cr, uid, ids, context): + """ + Default Attach Thunderbird Plug-in Installation File. + """ + data = {} + pdf_file = open(config['addons_path'] + "/thunderbird/doc/Installation Guide to OpenERP Thunderbid Plug-in.pdf", 'r') + data['pdf_file'] = base64.encodestring(pdf_file.read()) + self.write(cr, uid, ids, data) + return False + _columns = { - 'name':fields.char('File name', size=34, required=True, help='Save Thunderbird plugin file.'), + 'name':fields.char('File name', size=34), + 'pdf_name':fields.char('File name', size=64), 'thunderbird':fields.boolean('Thunderbird Module ', help="Allows you to select an object that you’d like to add to your email and its attachments."), 'plugin_file':fields.binary('Thunderbird Plug-in', readonly=True, help="Thunderbird plug-in file. Save as this file and install this plug-in in thunderbir."), - + 'pdf_file':fields.binary('Thunderbird Plug-in Installation File', help="The documentation file :- how to install Thunderbird Plug-in.", readonly=True), } + _defaults = { 'thunderbird' : True, 'name' : 'tiny_plugin-2.0.xpi', + 'pdf_name' : 'Installation Guide to OpenERP Thunderbid Plug-in.pdf', } thunderbird_installer() diff --git a/addons/thunderbird/installer.py.moved b/addons/thunderbird/installer.py.moved new file mode 100644 index 00000000000..69576aa2a46 --- /dev/null +++ b/addons/thunderbird/installer.py.moved @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from osv import fields +from osv import osv +from tools import config + +import base64 + +class thunderbird_installer(osv.osv_memory): + _name = 'thunderbird.installer' + _inherit = 'res.config.installer' + + def process_plugin(self, cr, uid, ids, context): + """ + Default Attach Thunderbird Plug-in File. + """ + data = {} + file = open(config['addons_path'] + "/thunderbird/plugin/tiny_plugin-2.0.xpi", 'r') + data['plugin_file'] = base64.encodestring(file.read()) + self.write(cr, uid, ids, data) + return False + + _columns = { + 'name':fields.char('File name', size=34, required=True, help='Save Thunderbird plugin file.'), + 'thunderbird':fields.boolean('Thunderbird Module ', help="Allows you to select an object that you’d like to add to your email and its attachments."), + 'plugin_file':fields.binary('Thunderbird Plug-in', readonly=True, help="Thunderbird plug-in file. Save as this file and install this plug-in in thunderbir."), + + } + _defaults = { + 'thunderbird' : True, + 'name' : 'tiny_plugin-2.0.xpi', + } + +thunderbird_installer() diff --git a/addons/thunderbird/partner/partner.py b/addons/thunderbird/partner/partner.py index 3aa190090a4..de5b5b9174c 100644 --- a/addons/thunderbird/partner/partner.py +++ b/addons/thunderbird/partner/partner.py @@ -92,9 +92,12 @@ class tinythunderbird_partner(osv.osv): partner=add_obj.read(cr,user,partner_ids,['partner_id']) if partner: dictcreate.update({'partner_id':partner[0]['partner_id'][0]}) +<<<<<<< TREE # search_id = self.pool.get('res.request.link').search(cr,user,[('object','=',dictcreate['ref'].split(',')[0])]) # if not search_id: # create_link_id = self.pool.get('res.request.link').create(cr,user,{'name':dictcreate['ref'].split(',')[0],'object':dictcreate['ref'].split(',')[0]}) +======= +>>>>>>> MERGE-SOURCE create_id = self.pool.get(dictcreate.get('object','crm.case')).create(cr, user, dictcreate) cases=case_pool.browse(cr,user,[create_id]) case_pool._history(cr, user, cases, _('Archive'), history=True, email=False) diff --git a/addons/thunderbird/plugin/tiny_plugin-2.0.xpi b/addons/thunderbird/plugin/tiny_plugin-2.0.xpi deleted file mode 100644 index ad92876d570..00000000000 Binary files a/addons/thunderbird/plugin/tiny_plugin-2.0.xpi and /dev/null differ diff --git a/addons/thunderbird/thunderbird_installer.xml b/addons/thunderbird/thunderbird_installer.xml index bd19a780456..59e0cc4f604 100644 --- a/addons/thunderbird/thunderbird_installer.xml +++ b/addons/thunderbird/thunderbird_installer.xml @@ -21,11 +21,15 @@ + - +