[IMP] knowledge: add the field server_address_port and improve the code
bzr revid: jap@tinyerp.com-20120327132721-a63fezw00ffkyzu2
This commit is contained in:
@@ -20,6 +20,8 @@
|
||||
##############################################################################
|
||||
|
||||
from osv import fields, osv
|
||||
from tools import config
|
||||
from lxml import etree
|
||||
|
||||
class knowledge_configuration(osv.osv_memory):
|
||||
_name = 'knowledge.configuration'
|
||||
@@ -27,28 +29,47 @@ class knowledge_configuration(osv.osv_memory):
|
||||
|
||||
_columns = {
|
||||
'module_wiki_quality_manual': fields.boolean('Use an internal wiki to group FAQ',
|
||||
help ="""
|
||||
It installs the wiki_quality_manual module.
|
||||
"""),
|
||||
help ="""It installs the wiki_quality_manual module."""),
|
||||
'module_wiki_faq': fields.boolean('Track quality with wiki',
|
||||
help ="""
|
||||
It install the wiki_faq.
|
||||
"""),
|
||||
help ="""It install the wiki_faq."""),
|
||||
'module_document_ftp': fields.boolean('Share repositories (FTP)',
|
||||
help ="""
|
||||
It install the document_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.
|
||||
"""),
|
||||
help ="""It assign server address/IP and port."""),
|
||||
'module_document_webdav': fields.boolean('Share Repositories (WebDAV)',
|
||||
help ="""
|
||||
It install the document_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:
|
||||
@@ -1,6 +1,7 @@
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
|
||||
<record id="view_knowledge_configuration" model="ir.ui.view">
|
||||
<field name="name">Knowledge Application</field>
|
||||
<field name="model">knowledge.configuration</field>
|
||||
@@ -16,6 +17,7 @@
|
||||
<group colspan="2" col="4">
|
||||
<field name="module_document_ftp"/>
|
||||
<field name="server_address_port"/>
|
||||
<newline/>
|
||||
<field name="module_document_webdav"/>
|
||||
</group>
|
||||
</form>
|
||||
@@ -31,7 +33,7 @@
|
||||
<field name="view_mode">form</field>
|
||||
</record>
|
||||
|
||||
<menuitem id="menu_knowledge_configuration" name="Knowledge" parent="base.menu_config" sequence="5" action="action_knowledge_configuration"/>
|
||||
<menuitem id="menu_knowledge_configuration" name="Knowledge" parent="base.menu_config" sequence="7" action="action_knowledge_configuration"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
Reference in New Issue
Block a user