[IMP] knowledge: remove field server_address_port from the res_config.py and add the configuration wizard in document_ftp module

bzr revid: jap@tinyerp.com-20120402083716-y7t0w1v0vof8v04z
This commit is contained in:
Jagdish Panchal (Open ERP)
2012-04-02 14:07:16 +05:30
parent 367d5c3fd9
commit de464e0209
6 changed files with 61 additions and 37 deletions
-30
View File
@@ -34,42 +34,12 @@ class knowledge_configuration(osv.osv_memory):
help ="""It install the wiki_faq."""),
'module_document_ftp': fields.boolean('Share repositories (FTP)',
help ="""It install the document_ftp."""),
'server_address_port': fields.char('Server address/IP and port',size=128,
help ="""It assign server address/IP and port."""),
'module_document_webdav': fields.boolean('Share Repositories (WebDAV)',
help ="""It install the document_webdav."""),
}
_defaults = {
'server_address_port': config.get('ftp_server_host', 'localhost') + ':' + config.get('ftp_server_port', '8021'),
}
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
res = super(knowledge_configuration, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=False)
ir_module = self.pool.get('ir.module.module')
module_id= ir_module.search(cr, uid, [('name','=','document_ftp')])
modle_state = ir_module.browse(cr,uid, module_id[0],context=context).state
doc = etree.XML(res['arch'])
nodes = doc.xpath("//field[@name='server_address_port']")
if modle_state == 'uninstalled':
for node in nodes:
node.set('invisible', '1')
res['arch'] = etree.tostring(doc)
return res
def set_ftp_configurations(self, cr, uid, ids, context=None):
data_pool = self.pool.get('ir.model.data')
ir_module = self.pool.get('ir.module.module')
module_id= ir_module.search(cr, uid, [('name','=','document_ftp')])
modle_state = ir_module.browse(cr,uid, module_id[0],context=context).state
if modle_state == 'installed':
conf = self.browse(cr, uid, ids[0], context=context)
doc_id = data_pool._get_id(cr, uid, 'document_ftp', 'action_document_browse')
doc_ids = data_pool.browse(cr, uid, doc_id, context=context).res_id
self.pool.get('ir.actions.url').write(cr, uid, [doc_ids], {'url': 'ftp://'+(conf.server_address_port or 'localhost:8021')+'/' + cr.dbname+'/'})
return True
knowledge_configuration()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+3 -5
View File
@@ -9,15 +9,13 @@
<field name="arch" type="xml">
<form string ="Knowledge Application">
<separator string="Wiki" colspan="4"/>
<group colspan="2" col="4">
<group colspan="4" col="4">
<field name="module_wiki_quality_manual"/>
<field name="module_wiki_faq"/>
</group>
<separator string="Document" colspan="4"/>
<group colspan="2" col="4">
<separator string="Documents" colspan="4"/>
<group colspan="4" col="4">
<field name="module_document_ftp"/>
<field name="server_address_port"/>
<newline/>
<field name="module_document_webdav"/>
</group>
</form>
+1 -1
View File
@@ -20,7 +20,7 @@
##############################################################################
import ftpserver
import wizard
import res_config
post_load = ftpserver.start_server
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+2 -1
View File
@@ -40,7 +40,8 @@ FTP client.
'update_xml': [
'wizard/ftp_configuration_view.xml',
'wizard/ftp_browse_view.xml',
'security/ir.model.access.csv'
'security/ir.model.access.csv',
'res_config_view.xml',
],
'demo_xml': [],
'test': [
+39
View File
@@ -0,0 +1,39 @@
# -*- 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 fields, osv
from tools import config
from lxml import etree
class documnet_ftp_configuration(osv.osv_memory):
_name = 'knowledge.configuration'
_inherit = 'knowledge.configuration'
_columns = {
'server_address_port': fields.char('Server address/IP and port',size=128,
help ="""It assign server address/IP and port."""),
}
_defaults = {
'server_address_port': config.get('ftp_server_host', 'localhost') + ':' + config.get('ftp_server_port', '8021'),
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+16
View File
@@ -0,0 +1,16 @@
<openerp>
<data>
<record id="view_document_ftp_configuration" model="ir.ui.view">
<field name="name">Knowledge Application</field>
<field name="model">knowledge.configuration</field>
<field name="type">form</field>
<field name="inherit_id" ref="document.view_knowledge_configuration"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='module_document_ftp']" position="after">
<field name="server_address_port"/>
</xpath>
</field>
</record>
</data>
</openerp>