1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as
9 # published by the Free Software Foundation, either version 3 of the
10 # License, or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Affero General Public License for more details.
17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ##############################################################################
22 from osv import osv, fields
23 # from tools.translate import _
24 from .. import ftpserver
26 class document_ftp_browse(osv.osv_memory):
27 _name = 'document.ftp.browse'
28 _description = 'Document FTP Browse'
31 'url' : fields.char('FTP Server', size=64, required=True),
34 def default_get(self, cr, uid, fields, context=None):
37 user_pool = self.pool.get('res.users')
38 current_user = user_pool.browse(cr, uid, uid, context=context)
39 data_pool = self.pool.get('ir.model.data')
40 aid = data_pool._get_id(cr, uid, 'document_ftp', 'action_document_browse')
41 aid = data_pool.browse(cr, uid, aid, context=context).res_id
42 ftp_url = self.pool.get('ir.actions.act_url').browse(cr, uid, aid, context=context)
43 url = ftp_url.url and ftp_url.url.split('ftp://') or []
49 url = '%s:%s' %(ftpserver.HOST, ftpserver.PORT)
50 res['url'] = 'ftp://%s@%s'%(current_user.login, url)
53 def browse_ftp(self, cr, uid, ids, context=None):
54 data_id = ids and ids[0] or False
55 data = self.browse(cr, uid, data_id, context=context)
58 'type': 'ir.actions.act_url',
65 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: