# -*- coding: utf-8 -*-
##############################################################################
#
#    OpenERP, Open Source Business Applications
#    Copyright (C) 2004-2012 OpenERP S.A. (<http://openerp.com>).
#
#    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 fields, osv
from tools import config

class documnet_ftp_setting(osv.osv_memory):
    _name = 'knowledge.configuration'
    _inherit = 'knowledge.configuration'
    _columns = {
        'document_ftp_url': fields.char('Browse Documents',size=64,
            help ="""It allow to browse the document from the relative URL""", readonly=True),               
    }

    def get_default_ftp_config(self, cr, uid, ids, context=None):
        ir_values = self.pool.get('ir.actions.url')
        user_pool = self.pool.get('res.users')
        current_user = user_pool.browse(cr, uid, uid, context=context)
        data_pool = self.pool.get('ir.model.data')
        aid = data_pool._get_id(cr, uid, 'document_ftp', 'action_document_browse')
        aid = data_pool.browse(cr, uid, aid, context=context).res_id
        ftp_url = self.pool.get('ir.actions.url').browse(cr, uid, aid, context=context)
        url = ftp_url.url and ftp_url.url.split('ftp://') or []
        if url:
            url = url[1]
            if url[-1] == '/':
                url = url[:-1]
        else:
            url = '%s:%s' %(ftpserver.HOST, ftpserver.PORT) 
        return {'document_ftp_url':'ftp://%s@%s'%(current_user.login, url)}

# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

@@ -1238,15 +1238,17 @@
 ts',
+ 
 size=
-64
+128
 ,%0A  
@@ -1270,16 +1270,21 @@
 =%22%22%22
-It allow
+Click the url
  to 
@@ -1306,30 +1306,9 @@
 ment
- from the relative URL
+s
 %22%22%22,
@@ -1392,17 +1392,20 @@
 r, uid, 
-i
+fiel
 ds, cont
@@ -1427,187 +1427,14 @@
     
-ir_values = self.pool.get('ir.actions.url')%0A        user_pool = self.pool.get('res.users')%0A        current_user = user_pool.browse(cr, uid, uid, context=context)%0A        data_pool
+action
  = s
@@ -1466,40 +1466,19 @@
 ta')
-%0A        aid = data_pool._get_id
+.get_object
 (cr,
@@ -1537,473 +1537,46 @@
     
-aid = data_pool.browse(cr, uid, aid, context=context).res_id%0A        ftp_url = self.pool.get('ir.actions.url').browse(cr, uid, aid, context=context)%0A        url = ftp_url.url and ftp_url.url.split('ftp://') or %5B%5D%0A        if url:%0A            url = url%5B1%5D%0A            if url%5B-1%5D == '/':%0A                url = url%5B:-1%5D%0A        else:%0A            url = '%25s:%25s' %25(ftpserver.HOST, ftpserver.PORT) %0A        return %7B'document_ftp_url':'ftp://%25s@%25s'%25(current_user.login, 
+return %7B'document_ftp_url': action.
 url
-)
 %7D%0A%0A#

simplify code of config wizard