1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
# -*- encoding: utf-8 -*-
##############################################################################
#
# Clock Reader for OpenERP
# Copyright (C) 2004-2009 Moldeo Interactive CT
# (<http://www.moldeointeractive.com.ar>). All Rights Reserved
# $Id$
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import osv, fields
from dropbox import client, rest, session
APP_KEY = 'c30f0xelp6qyzrd'
APP_SECRET = '3141l57uljvnjse'
ACCESS_TYPE = 'dropbox'
class dropbox_config(osv.osv_memory):
_name = 'wizard.dropbox.config'
_inherit = 'res.config' # mandatory
_columns = {
'url': fields.char('Field', size=128, required=True),
'token': fields.char('Field', size=64, required=True),
}
def execute(self, cr, uid, ids, context=None):
'do whatever configuration work you need here'
pass
dropbox_config()
"""
class dropbox_session(osv.osv, session.DropboxSession):
_name = "dropbox.session"
_description = "Dropbox session"
_columns = {
'name': fields.char('Name', size=64, required=True),
}
def link(self):
request_token = self.obtain_request_token()
url = self.build_authorized_url(request_token)
class dropbox_account(osv.osv):
_name = "dropbox.account"
_description = "Dropbox Account"
_columns = {
'name' : fields.char('Name', size=64, required=True),
'login': fields.char('Login', size=64, required=True),
'password': fields.char('Password', size=64, required=True),
'path': fields.char('Password', size=256, required=True),
'active': fields.boolean('Active'),
'backups': fields.one2many('dropbox.backup', 'account', 'Backups'),
}
def init(self):
self.sess = StoredSession(app_key, app_secret, access_type=ACCESS_TYPE)
self.
dropbox_account()
class dropbox_backup(osv.osv):
_name = "dropbox.backup"
_description = "Dropbox Backup"
_columns = {
'name': fields.char('Name', size=64, required=True),
'timestamp': fields.datetime('Timestamp', size=64, required=True),
'filename': fields.char('Filename', size=256, required=True),
'exists': fields.function(_exists, type='boolean', method=True, string='In Dropbox?'),
'account': fields.many2one('dropbox.account', ''),
}
dropbox_backup()
"""
|