From 0ca643e53127a8eb43cc46ad7008dcc922f93b6c Mon Sep 17 00:00:00 2001 From: "Jagdish Panchal (Open ERP)" Date: Fri, 23 Mar 2012 18:43:36 +0530 Subject: [PATCH 1/5] [IMP] knowledge: add the configuration wizard bzr revid: jap@tinyerp.com-20120323131336-88jmei14iuxh3vm8 --- addons/document/__init__.py | 1 + addons/document/__openerp__.py | 1 + addons/document/res_config.py | 54 +++++++++++++++++++++++++++++ addons/document/res_config_view.xml | 37 ++++++++++++++++++++ 4 files changed, 93 insertions(+) create mode 100644 addons/document/res_config.py create mode 100644 addons/document/res_config_view.xml diff --git a/addons/document/__init__.py b/addons/document/__init__.py index 12306b0499b..fd108da7fbc 100644 --- a/addons/document/__init__.py +++ b/addons/document/__init__.py @@ -28,5 +28,6 @@ import directory_report import document import report import wizard +import res_config # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/document/__openerp__.py b/addons/document/__openerp__.py index 6691ab53da3..ee34a8b01ec 100644 --- a/addons/document/__openerp__.py +++ b/addons/document/__openerp__.py @@ -55,6 +55,7 @@ ATTENTION: 'security/ir.model.access.csv', 'report/document_report_view.xml', 'board_document_view.xml', + 'res_config_view.xml', ], 'demo_xml': [ 'document_demo.xml','board_document_demo.xml'], 'test': [ diff --git a/addons/document/res_config.py b/addons/document/res_config.py new file mode 100644 index 00000000000..7bf27ae91ec --- /dev/null +++ b/addons/document/res_config.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# 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 . +# +############################################################################## + +from osv import fields, osv + +class knowledge_configuration(osv.osv_memory): + _name = 'knowledge.configuration' + _inherit = 'res.config.settings' + + _columns = { + 'module_wiki_quality_manual': fields.boolean('Use an internal wiki to group FAQ', + help =""" + It installs the wiki_quality_manual module. + """), + 'module_wiki_faq': fields.boolean('Track quality with wiki', + 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. + """), + + } + +knowledge_configuration() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/document/res_config_view.xml b/addons/document/res_config_view.xml new file mode 100644 index 00000000000..0794a9e8e86 --- /dev/null +++ b/addons/document/res_config_view.xml @@ -0,0 +1,37 @@ + + + + + Knowledge Application + knowledge.configuration + form + +
+ + + + + + + + + + + + +
+
+ + + Configure Knowledge Application + ir.actions.act_window + knowledge.configuration + + form + form + + + + +
+
From 367d5c3fd908761d1881514ca3aa340654468f38 Mon Sep 17 00:00:00 2001 From: "Jagdish Panchal (Open ERP)" Date: Tue, 27 Mar 2012 18:57:21 +0530 Subject: [PATCH 2/5] [IMP] knowledge: add the field server_address_port and improve the code bzr revid: jap@tinyerp.com-20120327132721-a63fezw00ffkyzu2 --- addons/document/res_config.py | 53 ++++++++++++++++++++--------- addons/document/res_config_view.xml | 4 ++- 2 files changed, 40 insertions(+), 17 deletions(-) diff --git a/addons/document/res_config.py b/addons/document/res_config.py index 7bf27ae91ec..e43d856880b 100644 --- a/addons/document/res_config.py +++ b/addons/document/res_config.py @@ -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: \ No newline at end of file diff --git a/addons/document/res_config_view.xml b/addons/document/res_config_view.xml index 0794a9e8e86..3d96d0df9e0 100644 --- a/addons/document/res_config_view.xml +++ b/addons/document/res_config_view.xml @@ -1,6 +1,7 @@ + Knowledge Application knowledge.configuration @@ -16,6 +17,7 @@ + @@ -31,7 +33,7 @@ form - + From de464e0209e82754d99ae092ff5117fbd93788af Mon Sep 17 00:00:00 2001 From: "Jagdish Panchal (Open ERP)" Date: Mon, 2 Apr 2012 14:07:16 +0530 Subject: [PATCH 3/5] [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 --- addons/document/res_config.py | 30 ------------------- addons/document/res_config_view.xml | 8 ++--- addons/document_ftp/__init__.py | 2 +- addons/document_ftp/__openerp__.py | 3 +- addons/document_ftp/res_config.py | 39 +++++++++++++++++++++++++ addons/document_ftp/res_config_view.xml | 16 ++++++++++ 6 files changed, 61 insertions(+), 37 deletions(-) create mode 100644 addons/document_ftp/res_config.py create mode 100644 addons/document_ftp/res_config_view.xml diff --git a/addons/document/res_config.py b/addons/document/res_config.py index e43d856880b..d9fa0dbd9dd 100644 --- a/addons/document/res_config.py +++ b/addons/document/res_config.py @@ -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: \ No newline at end of file diff --git a/addons/document/res_config_view.xml b/addons/document/res_config_view.xml index 3d96d0df9e0..b24984cac57 100644 --- a/addons/document/res_config_view.xml +++ b/addons/document/res_config_view.xml @@ -9,15 +9,13 @@
- + - - + + - - diff --git a/addons/document_ftp/__init__.py b/addons/document_ftp/__init__.py index b86320f9909..7ba25cb0540 100644 --- a/addons/document_ftp/__init__.py +++ b/addons/document_ftp/__init__.py @@ -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: diff --git a/addons/document_ftp/__openerp__.py b/addons/document_ftp/__openerp__.py index c10cd913f56..f6ab4616b2d 100644 --- a/addons/document_ftp/__openerp__.py +++ b/addons/document_ftp/__openerp__.py @@ -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': [ diff --git a/addons/document_ftp/res_config.py b/addons/document_ftp/res_config.py new file mode 100644 index 00000000000..556c0246832 --- /dev/null +++ b/addons/document_ftp/res_config.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# 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 . +# +############################################################################## + +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: \ No newline at end of file diff --git a/addons/document_ftp/res_config_view.xml b/addons/document_ftp/res_config_view.xml new file mode 100644 index 00000000000..07793c21baa --- /dev/null +++ b/addons/document_ftp/res_config_view.xml @@ -0,0 +1,16 @@ + + + + + Knowledge Application + knowledge.configuration + form + + + + + + + + + From 55be0622169fa14646100a0d100d6743bdf4dceb Mon Sep 17 00:00:00 2001 From: "Jagdish Panchal (Open ERP)" Date: Tue, 3 Apr 2012 18:21:12 +0530 Subject: [PATCH 4/5] [IMP] knowledge: improve the code in res_config.py for document_ftp module bzr revid: jap@tinyerp.com-20120403125112-vt9etd6kl0vdzzld --- addons/document/res_config.py | 6 ---- addons/document/res_config_view.xml | 2 +- addons/document_ftp/res_config.py | 38 +++++++++++++++++++------ addons/document_ftp/res_config_view.xml | 5 +++- 4 files changed, 34 insertions(+), 17 deletions(-) diff --git a/addons/document/res_config.py b/addons/document/res_config.py index d9fa0dbd9dd..ba0cbdfd60d 100644 --- a/addons/document/res_config.py +++ b/addons/document/res_config.py @@ -18,10 +18,7 @@ # along with this program. If not, see . # ############################################################################## - from osv import fields, osv -from tools import config -from lxml import etree class knowledge_configuration(osv.osv_memory): _name = 'knowledge.configuration' @@ -36,10 +33,7 @@ class knowledge_configuration(osv.osv_memory): help ="""It install the document_ftp."""), 'module_document_webdav': fields.boolean('Share Repositories (WebDAV)', help ="""It install the document_webdav."""), - } - - knowledge_configuration() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/document/res_config_view.xml b/addons/document/res_config_view.xml index b24984cac57..234d56be276 100644 --- a/addons/document/res_config_view.xml +++ b/addons/document/res_config_view.xml @@ -15,8 +15,8 @@ - +
diff --git a/addons/document_ftp/res_config.py b/addons/document_ftp/res_config.py index 556c0246832..43622ce2733 100644 --- a/addons/document_ftp/res_config.py +++ b/addons/document_ftp/res_config.py @@ -21,19 +21,39 @@ from osv import fields, osv from tools import config -from lxml import etree -class documnet_ftp_configuration(osv.osv_memory): +class documnet_ftp_setting(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."""), + 'url': fields.char('Borwse Documents',size=64, + help ="""It allow to browse the document from the relative URL""", readonly=True), } - - _defaults = { - 'server_address_port': config.get('ftp_server_host', 'localhost') + ':' + config.get('ftp_server_port', '8021'), - } - + 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 {'url':'ftp://%s@%s'%(current_user.login, url)} + + def document_ftp(self, cr, uid, ids, context=None): + data_id = ids and ids[0] or False + data = self.browse(cr, uid, data_id, context=context) + return { + 'type': 'ir.actions.act_url', + 'url':data.url, + 'nodestroy':True, + } + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/document_ftp/res_config_view.xml b/addons/document_ftp/res_config_view.xml index 07793c21baa..62347a0d56b 100644 --- a/addons/document_ftp/res_config_view.xml +++ b/addons/document_ftp/res_config_view.xml @@ -8,7 +8,10 @@ - + + +