diff --git a/addons/caldav/__init__.py b/addons/caldav/__init__.py
index 19f11301420..a7731ca526a 100644
--- a/addons/caldav/__init__.py
+++ b/addons/caldav/__init__.py
@@ -20,10 +20,10 @@
##############################################################################
import caldav
-import caldav_cache
-import caldav_fs
-import caldav_node
-import webdav_server
+#import caldav_cache
+#import caldav_fs
+#import caldav_node
+#import webdav_server
import wizard
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/caldav/__terp__.py b/addons/caldav/__terp__.py
index db6e46b1daa..1d25ad8cb77 100644
--- a/addons/caldav/__terp__.py
+++ b/addons/caldav/__terp__.py
@@ -49,7 +49,9 @@
"demo_xml" : [],
"update_xml" : [
'security/ir.model.access.csv',
- 'caldav_wizard.xml',
+ 'wizard/calendar_event_export_view.xml',
+ 'wizard/calendar_event_import_view.xml',
+ 'wizard/calendar_event_subscribe_view.xml',
'caldav_view.xml'
],
"installable" : True,
diff --git a/addons/caldav/caldav_wizard.xml b/addons/caldav/caldav_wizard.xml
deleted file mode 100644
index eaebba4234a..00000000000
--- a/addons/caldav/caldav_wizard.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/addons/caldav/wizard/__init__.py b/addons/caldav/wizard/__init__.py
index 4ab34601a96..1c45cb2a191 100755
--- a/addons/caldav/wizard/__init__.py
+++ b/addons/caldav/wizard/__init__.py
@@ -19,9 +19,8 @@
#
##############################################################################
-import wizard_cal_export
-import wizard_cal_import
-import wizard_cal_subscribe
+import calendar_event_export
+import calendar_event_import
+import calendar_event_subscribe
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/caldav/wizard/calendar_event_export.py b/addons/caldav/wizard/calendar_event_export.py
new file mode 100644
index 00000000000..3bee5a5089f
--- /dev/null
+++ b/addons/caldav/wizard/calendar_event_export.py
@@ -0,0 +1,69 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 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, osv
+from tools.translate import _
+import netsvc
+import pooler
+import time
+import tools
+import wizard
+import base64
+
+class calendar_event_export(osv.osv_memory):
+ """
+ Export Calendar Event.
+ """
+ def _process_export_ics(self, cr, uid, context):
+ """
+ Get Default value for file_path field.
+ """
+ model = context.get('model', 'basic.calendar')
+ model_obj = self.pool.get(model)
+ calendar = model_obj.export_cal(cr, uid, context['active_ids'], context)
+ #TODO: check why returns wrong value
+ return base64.encodestring(calendar)
+
+ def _process_export_ics_name(self, cr, uid, context):
+ """
+ Get Default value for Name field.
+ """
+ model = context.get('model', 'basic.calendar')
+ model_obj = self.pool.get(model)
+ calendar = model_obj.export_cal(cr, uid, context['active_ids'], context)
+ return 'OpenERP %s.ics' % (model_obj._description)
+
+ _name = "calendar.event.export"
+ _description = "Event Export"
+ _columns = {
+ 'file_path':fields.binary('Save ICS file', filters='*.ics', required=True),
+ 'name':fields.char('File name', size=34, required=True, help='Save in .ics format')
+ }
+
+ _defaults={
+ 'name':_process_export_ics_name,
+ 'file_path':_process_export_ics
+ }
+
+calendar_event_export()
+
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/caldav/wizard/calendar_event_export_view.xml b/addons/caldav/wizard/calendar_event_export_view.xml
new file mode 100644
index 00000000000..0a049e15083
--- /dev/null
+++ b/addons/caldav/wizard/calendar_event_export_view.xml
@@ -0,0 +1,49 @@
+
+
+
+
+ calendar.event.export.form
+ calendar.event.export
+ form
+
+
+
+
+
+
+ Export .ics File
+ calendar.event.export
+ form
+ tree,form
+
+ new
+ {'record_id':active_id}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/addons/caldav/wizard/calendar_event_import.py b/addons/caldav/wizard/calendar_event_import.py
new file mode 100644
index 00000000000..ba72e1c8c6d
--- /dev/null
+++ b/addons/caldav/wizard/calendar_event_import.py
@@ -0,0 +1,78 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 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, osv
+from tools.translate import _
+import netsvc
+import pooler
+import time
+import tools
+import wizard
+import base64
+
+class calendar_event_import(osv.osv_memory):
+ """
+ Import Calendar Event.
+ """
+ cnt = 0
+ def _process_imp_ics(self, cr, uid, ids, context=None):
+ """
+ Process Import ics File.
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param ids: List of calendar event import’s IDs
+ @return: dictionary of calendar evet import window with Import successful msg.
+ """
+ for data in self.read(cr, uid, ids):
+ model = data.get('model', 'basic.calendar')
+ model_obj = self.pool.get(model)
+ context.update({'model': model})
+ data_obj = self.pool.get('ir.model.data')
+ id2 = data_obj._get_id(cr, uid, 'caldav', 'view_calendar_event_import_display')
+ if id2:
+ id2 = data_obj.browse(cr, uid, id2, context=context).res_id
+ vals = model_obj.import_cal(cr, uid, data['file_path'], context['active_id'], context)
+ global cnt
+ if vals:
+ cnt = len(vals)
+ value = {
+ 'view_type': 'form',
+ 'view_mode': 'form',
+ 'res_model': 'calendar.event.import',
+ 'views': [(id2,'form'),(False,'tree'),(False,'calendar'),(False,'graph')],
+ 'type': 'ir.actions.act_window',
+ 'target': 'new'
+ }
+ return value
+
+ _name = "calendar.event.import"
+ _description = "Event Import"
+ _columns = {
+ 'file_path': fields.binary('Select ICS file', filters='*.ics', required=True),
+ 'msg': fields.text('', readonly=True),
+ }
+ _defaults={
+ 'msg':lambda *a:'Import Sucessful'
+ }
+
+calendar_event_import()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/caldav/wizard/calendar_event_import_view.xml b/addons/caldav/wizard/calendar_event_import_view.xml
new file mode 100644
index 00000000000..1fbd89b2499
--- /dev/null
+++ b/addons/caldav/wizard/calendar_event_import_view.xml
@@ -0,0 +1,61 @@
+
+
+
+
+ calendar.event.import.form
+ calendar.event.import
+ form
+
+
+
+
+
+
+ calendar.event.import.form.display
+ calendar.event.import
+ form
+
+
+
+
+
+
+ Import .ics File
+ calendar.event.import
+ form
+ tree,form
+
+ new
+ {'record_id':active_id}
+
+
+
+
+
+ Import .ics File
+ client_action_multi
+
+ action
+ basic.calendar
+
+
+
+
diff --git a/addons/caldav/wizard/calendar_event_subscribe.py b/addons/caldav/wizard/calendar_event_subscribe.py
new file mode 100644
index 00000000000..aa539938877
--- /dev/null
+++ b/addons/caldav/wizard/calendar_event_subscribe.py
@@ -0,0 +1,89 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 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, osv
+from tools.translate import _
+import netsvc
+import pooler
+import time
+import tools
+import wizard
+import base64
+import urllib
+
+class calendar_event_subscribe(osv.osv_memory):
+ """
+ Subscribe Calendar Event.
+ """
+ cnt = 0
+ def _process_imp_ics(self, cr, uid, ids, context=None):
+ """
+ process ics file.
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param ids: List of calendar event subscribe’s IDs
+ @return: dictionary of calendar evet subscribe window with Import successful msg.
+ """
+ global cnt
+ for data in self.read(cr, uid, ids):
+ try:
+ f = urllib.urlopen(data['url_path'])
+ caldata = f.fp.read()
+ f.close()
+ except Exception,e:
+ raise osv.except_osv(_('Error!'), _('Please provide Proper URL !'))
+ model = data.get('model', 'basic.calendar')
+ model_obj = self.pool.get(model)
+ context.update({'url': data['url_path'],
+ 'model': data.get('model', 'basic.calendar')})
+ vals = model_obj.import_cal(cr, uid, base64.encodestring(caldata), \
+ context['active_id'], context)
+ if vals:
+ cnt = vals['count']
+ data_obj = self.pool.get('ir.model.data')
+ id2 = data_obj._get_id(cr, uid, 'caldav', 'view_calendar_event_subscribe_display')
+ if id2:
+ id2 = data_obj.browse(cr, uid, id2, context=context).res_id
+
+ value = {
+ 'view_type': 'form',
+ 'view_mode': 'form',
+ 'res_model': 'calendar.event.subscribe',
+ 'views': [(id2,'form'),(False,'tree'),(False,'calendar'),(False,'graph')],
+ 'type': 'ir.actions.act_window',
+ 'target': 'new'
+ }
+ return value
+
+ _name = "calendar.event.subscribe"
+ _description = "Event subscribe"
+ _columns = {
+ 'url_path': fields.char('Provide path for remote calendar', size=124, required=True),
+ 'msg': fields.text('', readonly=True),
+ }
+ _defaults={
+ 'msg':lambda *a:'Import Sucessful.'
+ }
+
+calendar_event_subscribe()
+
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/caldav/wizard/calendar_event_subscribe_view.xml b/addons/caldav/wizard/calendar_event_subscribe_view.xml
new file mode 100644
index 00000000000..95c06c20f6e
--- /dev/null
+++ b/addons/caldav/wizard/calendar_event_subscribe_view.xml
@@ -0,0 +1,61 @@
+
+
+
+
+ calendar.event.subscribe.form
+ calendar.event.subscribe
+ form
+
+
+
+
+
+
+ calendar.event.subscribe.form.display
+ calendar.event.subscribe
+ form
+
+
+
+
+
+
+ Subscribe
+ calendar.event.subscribe
+ form
+ tree,form
+
+ new
+ {'record_id':active_id}
+
+
+
+
+
+ Subscribe
+ client_action_multi
+
+ action
+ basic.calendar
+
+
+
+
\ No newline at end of file
diff --git a/addons/caldav/wizard/wizard_cal_export.py b/addons/caldav/wizard/wizard_cal_export.py
deleted file mode 100644
index f7896c738d7..00000000000
--- a/addons/caldav/wizard/wizard_cal_export.py
+++ /dev/null
@@ -1,65 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 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 .
-#
-##############################################################################
-
-import wizard
-import base64
-import pooler
-
-
-class cal_event_export_wizard(wizard.interface):
- form1 = '''
- '''
-
- form1_fields = {
- 'file_path': {
- 'string': 'Save ICS file',
- 'type': 'binary',
- 'required': True,
- 'filters': '*.ics'
- },
- 'name': {
- 'string': 'File name',
- 'type': 'char',
- 'size': 34,
- 'required': True,
- 'help': 'Save in .ics format'},
- }
-
- def _process_export_ics(self, cr, uid, data, context):
- model = data.get('model')
- model_obj = pooler.get_pool(cr.dbname).get(model)
- calendar = model_obj.export_cal(cr, uid, data['ids'], context)
- return {'file_path': base64.encodestring(calendar), \
- 'name': 'OpenERP %s.ics' % (model_obj._description)}
-
- states = {
- 'init': {
- 'actions': [_process_export_ics],
- 'result': {'type': 'form', 'arch':form1, 'fields':form1_fields, \
- 'state': [('end', '_Cancel', 'gtk-cancel')]}},
- }
-
-cal_event_export_wizard('calendar.event.export')
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/caldav/wizard/wizard_cal_import.py b/addons/caldav/wizard/wizard_cal_import.py
deleted file mode 100644
index a5670f545fa..00000000000
--- a/addons/caldav/wizard/wizard_cal_import.py
+++ /dev/null
@@ -1,88 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 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 .
-#
-##############################################################################
-
-import wizard
-import pooler
-
-
-class cal_event_import_wizard(wizard.interface):
- form1 = '''
- '''
-
- form1_fields = {
- 'file_path': {
- 'string': 'Select ICS file',
- 'type': 'binary',
- 'required': True,
- 'filters': '*.ics'
- }
- }
- display = '''
- '''
-
- display_fields = {
- 'msg': {
- 'string': '',
- 'type': 'text',
- 'readonly': True,
- }
- }
-
- def _process_imp_ics(self, cr, uid, data, context=None):
- model = data.get('model')
- model_obj = pooler.get_pool(cr.dbname).get(model)
- context.update({'model': model})
- vals = model_obj.import_cal(cr, uid, data['form']['file_path'], data['id'], context)
- global cnt
- cnt = 0
- if vals:
- cnt = len(vals)
- return {}
-
- def _result_set(self, cr, uid, data, context=None):
- msg = (cnt and "Imported %s components" % cnt) or 'Import Sucessful'
- return {'msg': msg}
-
- states = {
- 'init': {
- 'actions': [],
- 'result': {'type': 'form', 'arch': form1, 'fields': form1_fields, \
- 'state': [('end', '_Cancel', 'gtk-cancel'), ('open', '_Import', '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')]}
- },
- }
-
-cal_event_import_wizard('calendar.event.import')
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/caldav/wizard/wizard_cal_subscribe.py b/addons/caldav/wizard/wizard_cal_subscribe.py
deleted file mode 100644
index 709c61d0b25..00000000000
--- a/addons/caldav/wizard/wizard_cal_subscribe.py
+++ /dev/null
@@ -1,97 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 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 tools.translate import _
-import base64
-import pooler
-import urllib
-import wizard
-
-class cal_event_subscribe_wizard(wizard.interface):
- form1 = '''
- '''
-
- form1_fields = {
- 'url_path': {
- 'string': 'Provide path for remote calendar',
- 'type': 'char',
- 'required': True,
- 'size': 124
- }
- }
- display = '''
- '''
-
- display_fields = {
- 'msg': {
- 'string': '',
- 'type': 'text',
- 'readonly': True,
- }
- }
-
- def _process_imp_ics(self, cr, uid, data, context=None):
- global cnt
- cnt = 0
- try:
- f = urllib.urlopen(data['form']['url_path'])
- caldata = f.fp.read()
- f.close()
- except Exception,e:
- raise wizard.except_wizard(_('Error!'), _('Please provide Proper URL !'))
- model = data.get('model')
- model_obj = pooler.get_pool(cr.dbname).get(model)
- context.update({'url': data['form']['url_path'],
- 'model': data.get('model')})
- vals = model_obj.import_cal(cr, uid, base64.encodestring(caldata), \
- data['id'], context)
- if vals:
- cnt = vals['count']
- return {}
-
- def _result_set(self, cr, uid, data, context=None):
- return {'msg': 'Import Sucessful.'}
-
- 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')]}
- },
- }
-
-cal_event_subscribe_wizard('calendar.event.subscribe')
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: