[ADD]: crm: Added new wizard to subscibe remote calendar

bzr revid: rpa@tinyerp.com-20091228133659-h8fd924a6j36ds5w
This commit is contained in:
rpa (Open ERP)
2009-12-28 19:06:59 +05:30
parent 90508e76f0
commit 0cd8698904
4 changed files with 98 additions and 2 deletions
+4
View File
@@ -4,6 +4,10 @@
name="caldav.crm.import" id="wizard_crm_cal_import" multi="True"
/>
<wizard string="Subscribe to a Remote calendar" model="crm.case"
name="caldav.crm.subscribe" id="wizard_crm_cal_subscribe" multi="True"
/>
<wizard string="Export ICS File" model="crm.case" name="caldav.crm.export"
id="wizard_crm_cal_export" multi="True"
/>
+3 -2
View File
@@ -104,7 +104,7 @@ class crm_case(osv.osv):
'freebusy' : fields.text('FreeBusy'),
'transparent' : fields.selection([('TRANSPARENT', 'TRANSPARENT'), \
('OPAQUE', 'OPAQUE')], 'Trensparent'),
'caldav_url' : fields.char('Caldav URL', size=34),
'caldav_url' : fields.char('Caldav URL', size=264),
'exdate' : fields.text('Exception Date/Times', help="This property defines the list\
of date/time exceptions for arecurring calendar component."),
'exrule' : fields.text('Exception Rule', help="defines a rule or repeating pattern\
@@ -204,7 +204,8 @@ class crm_case(osv.osv):
val.update({'section_id' : section_id})
is_exists = common.uid2openobjectid(cr, val['id'], self._name )
val.pop('id')
val.pop('create_date')
if val.has_key('create_date'): val.pop('create_date')
val['caldav_url'] = context.get('url') or ''
if is_exists:
self.write(cr, uid, [is_exists], val)
else:
+1
View File
@@ -25,6 +25,7 @@ import wizard_crm_new_send_email
import wizard_fetch_mail
import wizard_cal_export
import wizard_cal_import
import wizard_cal_subscribe
import meeting_planify
import wizard_partner_create
+90
View File
@@ -0,0 +1,90 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
import pooler
import urllib
import base64
class crm_cal_subscribe_wizard(wizard.interface):
form1 = '''<?xml version="1.0"?>
<form string="Subscribe to Remote ICS">
<separator string="Provide path for Remote Calendar"/>
<field name="url_path" colspan="4" width="300" nolabel="1" widget="url"/>
</form>'''
form1_fields = {
'url_path': {
'string': 'Provide path for remote calendar',
'type': 'char',
'required': True,
'size': 124
}
}
display = '''<?xml version="1.0"?>
<form string="Message...">
<field name="msg" colspan="4" width="300" nolabel="1"/>
</form>'''
display_fields = {
'msg': {
'string': '',
'type': 'text',
'readonly': True,
}
}
def _process_imp_ics(self, cr, uid, data, context=None):
global cnt
cnt = 0
f = urllib.urlopen(data['form']['url_path'])
caldata= f.fp.read()
f.close()
case_obj = pooler.get_pool(cr.dbname).get('crm.case')
context.update({'url': data['form']['url_path']})
vals = case_obj.import_cal(cr, uid, base64.encodestring(caldata), context)
if vals:
cnt = vals['count']
return {}
def _result_set(self, cr, uid, data, context=None):
return {'msg': 'Subscribed %s Event(s)' % cnt}
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch': form1, 'fields': form1_fields, \
'state': [('end', '_Cancel', 'gtk-cancel'), ('open', '_Subscribe', 'gtk-ok')]}
},
'open': {
'actions': [],
'result': {'type': 'action', 'action': _process_imp_ics, 'state': 'display'}
},
'display': {
'actions': [_result_set],
'result': {'type': 'form', 'arch': display, 'fields': display_fields, \
'state': [('end', 'Ok', 'gtk-ok')]}
},
}
crm_cal_subscribe_wizard('caldav.crm.subscribe')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: