diff options
| author | Fabien Pinckaers <fp@tinyerp.com> | 2009-12-28 21:29:46 +0100 |
|---|---|---|
| committer | Fabien Pinckaers <fp@tinyerp.com> | 2009-12-28 21:29:46 +0100 |
| commit | d5a634982be4e024387fb709d2d5e08eb401c1b2 (patch) | |
| tree | d9245256e5087d5236c407f547388d62256fb6b1 | |
| parent | 23b6907ea04ad6c21e130c22cdfc5c60606b6d18 (diff) | |
| parent | 0cd86989040e5f81efdb2fc4d9ec18f1730d0569 (diff) | |
merge
bzr revid: fp@tinyerp.com-20091228202946-0mjav6367fby9vph
| -rw-r--r-- | addons/crm/crm_caldav_wizard.xml | 4 | ||||
| -rw-r--r-- | addons/crm/crm_calendar.py | 5 | ||||
| -rw-r--r-- | addons/crm/wizard/__init__.py | 1 | ||||
| -rw-r--r-- | addons/crm/wizard/wizard_cal_subscribe.py | 90 |
4 files changed, 98 insertions, 2 deletions
diff --git a/addons/crm/crm_caldav_wizard.xml b/addons/crm/crm_caldav_wizard.xml index 7ff8d305640..fa20285638d 100644 --- a/addons/crm/crm_caldav_wizard.xml +++ b/addons/crm/crm_caldav_wizard.xml @@ -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" /> diff --git a/addons/crm/crm_calendar.py b/addons/crm/crm_calendar.py index ab74724b938..f321138a2dd 100644 --- a/addons/crm/crm_calendar.py +++ b/addons/crm/crm_calendar.py @@ -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: diff --git a/addons/crm/wizard/__init__.py b/addons/crm/wizard/__init__.py index bcaad7e61ae..95d42ca9c5f 100644 --- a/addons/crm/wizard/__init__.py +++ b/addons/crm/wizard/__init__.py @@ -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 diff --git a/addons/crm/wizard/wizard_cal_subscribe.py b/addons/crm/wizard/wizard_cal_subscribe.py new file mode 100644 index 00000000000..5b312a11e67 --- /dev/null +++ b/addons/crm/wizard/wizard_cal_subscribe.py @@ -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:
\ No newline at end of file |
