[MERGE]: Merge with lp:~openerp-dev/openobject-addons/tfr-addons-caldav-doc

bzr revid: atp@tinyerp.co.in-20110107062507-xrxg10sb3yn6dl3t
This commit is contained in:
atp (Open ERP)
2011-01-07 11:55:07 +05:30
6 changed files with 234 additions and 2 deletions
+1
View File
@@ -56,6 +56,7 @@
'wizard/calendar_event_export_view.xml',
'wizard/calendar_event_import_view.xml',
'wizard/calendar_event_subscribe_view.xml',
'wizard/caldav_browse_view.xml',
'caldav_view.xml',
'caldav_setup.xml'
],
+1 -1
View File
@@ -22,5 +22,5 @@
import calendar_event_export
import calendar_event_import
import calendar_event_subscribe
import caldav_browse
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+155
View File
@@ -0,0 +1,155 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 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/>.
#
##############################################################################
from osv import osv, fields
from tools import config
import base64
import addons
from tools.translate import _
class caldav_browse(osv.osv_memory):
__doc = {'other' : _("""
* Webdav server that provides remote access to calendar
* Synchronisation of calendar using WebDAV
* Customize calendar event and todo attribute with any of OpenERP model
* Provides iCal Import/Export functionality
To access Calendars using CalDAV clients, point them to:
http://HOSTNAME:PORT/webdav/DATABASE_NAME/calendars/users/USERNAME/c
To access OpenERP Calendar using WebCal to remote site use the URL like:
http://HOSTNAME:PORT/webdav/DATABASE_NAME/Calendars/CALENDAR_NAME.ics
Where,
HOSTNAME: Host on which OpenERP server(With webdav) is running
PORT : Port on which OpenERP server is running (By Default : 8069)
DATABASE_NAME: Name of database on which OpenERP Calendar is created
CALENDAR_NAME: Name of calendar to access
"""),
'iphone' : _("""It's complicated""")}
_name = 'caldav.browse'
_description = 'Caldav Browse'
_columns = {
'url' : fields.char('Caldav Server', size=264, required=True, help="Url of the caldav server, use for synchronization"),
'caldav_doc_file':fields.binary('Caldav Document', readonly=True, help="download full caldav Documentation."),
'description':fields.text('Description', readonly=True)
}
def default_get(self, cr, uid, fields, context=None):
res = {}
host = ''
port = ''
prefix = 'http://'
if not config.get('xmlrpc'):
if not config.get('netrpc'):
prefix = 'https://'
host = config.get('xmlrpcs_interface', None)
port = config.get('xmlrpcs_port', 8071)
else:
host = config.get('netrpc_interface', None)
port = config.get('netrpc_port',8070)
else:
host = config.get('xmlrpc_interface', None)
port = config.get('xmlrpc_port',8069)
if host == '' or None:
host = 'localhost'
port = 8069
if not config.get_misc('webdav','enable',True):
raise Exception("WebDAV is disabled, cannot continue")
user_pool = self.pool.get('res.users')
current_user = user_pool.browse(cr, uid, uid, context=context)
pref_obj = self.pool.get('user.preference')
pref_ids = pref_obj.browse(cr, uid ,context.get('rec_id',False), context=context)
#TODO write documentation
res['description'] = self.__doc['other']
if pref_ids:
pref_ids = pref_ids[0]
url = host + ':' + str(port) + '/'+ pref_ids.service + '/' + cr.dbname + '/'+'calendars/'+ 'users/'+ current_user.login + '/'+ pref_ids.collection.name+ '/'+ pref_ids.calendar.name
res['description'] = self.__doc.get(pref_ids.device , self.__doc['other'])
file = open(addons.get_module_resource('caldav','doc', 'Caldav_doc.pdf'),'rb')
res['caldav_doc_file'] = base64.encodestring(file.read())
res['url'] = prefix+url
return res
def browse_caldav(self, cr, uid, ids, context):
return {}
caldav_browse()
class user_preference(osv.osv_memory):
_name = 'user.preference'
_description = 'User preference Form'
_columns = {
'collection' :fields.many2one('document.directory', "Calendar Collection", required=True, domain = [('calendar_collection', '=', True)]),
'calendar' :fields.many2one('basic.calendar', 'Calendar', required=True),
'service': fields.selection([('webdav','CalDAV')], "Services"),
'device' : fields.selection([('other', 'Other'), ('iphone', 'iPhone'), ('android', 'Android based device'),('thunderbird', 'Sunbird/Thunderbird'), ('evolution','Evolution')], "Software/Devices")
}
def _get_default_calendar(self, cr, uid, context):
if context == None:
context = {}
name = context.get('cal_name')
collection_obj = self.pool.get('basic.calendar')
ids = collection_obj.search(cr, uid, [('name', '=', name)])
return ids[0]
def _get_default_collection(self, cr, uid, context):
collection_obj = self.pool.get('document.directory')
ids = collection_obj.search(cr, uid, [('name', '=', 'c')])
return ids[0]
_defaults={
'service': 'webdav',
'collection' : _get_default_collection,
'calendar' : _get_default_calendar,
'device' : 'other'
}
def open_window(self, cr, uid, ids, context=None):
obj_model = self.pool.get('ir.model.data')
model_data_ids = obj_model.search(cr,uid,[('model','=','ir.ui.view'),('name','=','caldav_Browse')])
resource_id = obj_model.read(cr, uid, model_data_ids, fields=['res_id'])
context.update({'rec_id': ids})
return {
'view_type': 'form',
'view_mode': 'form',
'res_model': 'caldav.browse',
'views': [(resource_id,'form')],
'type': 'ir.actions.act_window',
'target': 'new',
'context': context,
}
user_preference()
@@ -0,0 +1,51 @@
<?xml version="1.0"?>
<openerp>
<data>
<record id="caldav_browse_form" model="ir.ui.view">
<field name="name">caldav_Browse</field>
<field name="model">caldav.browse</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Browse caldav" >
<group colspan="4" width="700" height="500">
<separator string="Browse caldav" colspan="4"/>
<field name="url" colspan="4" />
<separator string="Description" colspan="4"/>
<field name="description" colspan="4" nolabel="1"/>
<separator colspan="4"/>
<field name="caldav_doc_file" colspan="4" />
<group col="4" colspan="4">
<label string="" colspan="2"/>
<button name="browse_caldav" string="_Ok" type="object" icon="gtk-ok"/>
</group>
</group>
</form>
</field>
</record>
<record id="user_prefernce_form" model="ir.ui.view">
<field name="name">user_preference</field>
<field name="model">user.preference</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="User Preference">
<separator string="" colspan="4"/>
<field name="service" colspan="4" width="250" readonly="1"/>
<field name="collection" colspan="4" width="250" invisible="1" />
<field name="calendar" colspan="4" width="250" domain="[('collection_id','=', collection)]" readonly="1"/>
<field name="device" colspan="4" width="250" />
<separator colspan="4"/>
<group col="4" colspan="4">
<label string="" colspan="2"/>
<button special="cancel" string="_Cancel" icon="gtk-cancel"/>
<button name="open_window" string="_Open" type="object" icon="gtk-ok"/>
</group>
</form>
</field>
</record>
</data>
</openerp>
+2 -1
View File
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
##############################################################################
#
@@ -36,7 +37,7 @@
'crm_caldav_setup.xml',
],
'update_xml': [],
'update_xml': ['crm_caldav_view.xml'],
'demo_xml': [],
'installable': True,
'active': False,
+24
View File
@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<openerp>
<data>
<record id="action_caldav_browse" model="ir.actions.act_window">
<field name="name">Caldav Browse</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">user.preference</field>
<field name="view_id" ref="caldav.user_prefernce_form"/>
<field name="context">{'cal_name' : 'Meetings'}</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<menuitem
name="Synchronyze this calendar"
action="action_caldav_browse"
id="menu_caldav_browse"
icon="STOCK_EXECUTE"
parent="crm.menu_meeting_sale" sequence="1"/>
</data>
</openerp>