summaryrefslogtreecommitdiff
path: root/addons/document_ftp/wizard
diff options
context:
space:
mode:
authorMod2 Team (OpenERP) <>2010-06-24 15:18:27 +0530
committerHarry (OpenERP) <hmo@tinyerp.com>2010-06-24 15:18:27 +0530
commit02a17546b8ea3a9b3a8cbd89e1a0c954f4639845 (patch)
tree5dcdf94baa7dae9baad7b36ce25189fad4843a45 /addons/document_ftp/wizard
parent666c9db5f76ec21788623d975dda00f4f913f7f6 (diff)
[IMP] Document:
* Add new configuration wizard to set resource directiory for Sale order, Product or Project * Support pptx2txt, docx2txt in content index. * Add new configuration wizard to browse FTP Server in document_ftp module * Improved Configuration wizard to set url of FTP Server bzr revid: hmo@tinyerp.com-20100624094827-9yfmtiiegoiu0asa
Diffstat (limited to 'addons/document_ftp/wizard')
-rw-r--r--addons/document_ftp/wizard/__init__.py25
-rw-r--r--addons/document_ftp/wizard/ftp_browse.py61
-rw-r--r--addons/document_ftp/wizard/ftp_browse_view.xml40
-rw-r--r--addons/document_ftp/wizard/ftp_configuration.py55
-rw-r--r--addons/document_ftp/wizard/ftp_configuration_view.xml53
5 files changed, 234 insertions, 0 deletions
diff --git a/addons/document_ftp/wizard/__init__.py b/addons/document_ftp/wizard/__init__.py
new file mode 100644
index 00000000000..40997cc6b90
--- /dev/null
+++ b/addons/document_ftp/wizard/__init__.py
@@ -0,0 +1,25 @@
+# -*- 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/>.
+#
+##############################################################################
+import ftp_browse
+import ftp_configuration
+
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/document_ftp/wizard/ftp_browse.py b/addons/document_ftp/wizard/ftp_browse.py
new file mode 100644
index 00000000000..d033302f22a
--- /dev/null
+++ b/addons/document_ftp/wizard/ftp_browse.py
@@ -0,0 +1,61 @@
+# -*- 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 osv, fields
+from tools.translate import _
+from document_ftp import ftpserver
+class document_ftp_browse(osv.osv_memory):
+ _name = 'document.ftp.browse'
+ _description = 'Document FTP Browse'
+
+ _columns = {
+ 'url' : fields.char('FTP Server', size=64, required=True),
+ }
+
+ def default_get(self, cr, uid, fields, context=None):
+ res = {}
+ if 'url' in fields:
+ user_pool = self.pool.get('res.users')
+ current_user = user_pool.browse(cr, uid, uid, context=context)
+ dir_pool = self.pool.get('document.directory')
+ 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]
+ else:
+ url = '%s:%s' %(ftpserver.HOST, ftpserver.PORT)
+ res['url'] = 'ftp://%s@%s'%(current_user.login, url)
+ return res
+
+ def browse_ftp(self, cr, uid, ids, context):
+ data_id = ids and ids[0] or False
+ data = self.browse(cr, uid, data_id, context)
+ final_url = data.url
+ return {
+ 'type': 'ir.actions.act_url',
+ 'url':final_url,
+ 'target': 'new'
+ }
+document_ftp_browse()
+
diff --git a/addons/document_ftp/wizard/ftp_browse_view.xml b/addons/document_ftp/wizard/ftp_browse_view.xml
new file mode 100644
index 00000000000..44cedccfc3e
--- /dev/null
+++ b/addons/document_ftp/wizard/ftp_browse_view.xml
@@ -0,0 +1,40 @@
+<openerp>
+ <data>
+
+ <record id="ftp_browse_form" model="ir.ui.view">
+ <field name="name">Document FTP Browse</field>
+ <field name="model">document.ftp.browse</field>
+ <field name="type">form</field>
+ <field name="arch" type="xml">
+ <form string="Browse Document">
+ <separator string="Browse Document" colspan="4"/>
+ <field name="url" widget="url" colspan="4"/>
+ <separator colspan="4"/>
+ <group col="4" colspan="4">
+ <label string="" colspan="2"/>
+ <button special="cancel" string="_Close" icon="gtk-cancel"/>
+ <button name="browse_ftp" string="_Browse" type="object" icon="gtk-ok"/>
+ </group>
+ </form>
+ </field>
+ </record>
+
+ <record id="action_ftp_browse" model="ir.actions.act_window">
+ <field name="name">Document Browse</field>
+ <field name="type">ir.actions.act_window</field>
+ <field name="res_model">document.ftp.browse</field>
+ <field name="view_id" ref="ftp_browse_form"/>
+ <field name="view_type">form</field>
+ <field name="view_mode">form</field>
+ <field name="target">new</field>
+ </record>
+
+ <menuitem
+ name="Shared Repository (FTP)"
+ action="action_ftp_browse"
+ id="menu_document_browse"
+ icon="STOCK_EXECUTE"
+ parent="document.menu_document_doc" sequence="1"/>
+
+</data>
+</openerp>
diff --git a/addons/document_ftp/wizard/ftp_configuration.py b/addons/document_ftp/wizard/ftp_configuration.py
new file mode 100644
index 00000000000..40926bdf7c9
--- /dev/null
+++ b/addons/document_ftp/wizard/ftp_configuration.py
@@ -0,0 +1,55 @@
+# -*- 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/>
+#
+##############################################################################
+
+import base64
+
+from osv import osv, fields
+from osv.orm import except_orm
+from tools import config
+import urlparse
+
+import os
+
+class document_ftp_configuration(osv.osv_memory):
+
+ _name='document.ftp.configuration'
+ _description = 'Auto Directory Configuration'
+ _inherit = 'res.config'
+ _rec_name = 'host'
+ _columns = {
+ 'host': fields.char('Address', size=64,
+ help="Server address or IP and port to which users should connect to for DMS access",
+ required=True),
+ }
+
+ _defaults = {
+ 'host': config.get('ftp_server_host', 'localhost') + ':' + config.get('ftp_server_port', '8021'),
+ }
+
+ def execute(self, cr, uid, ids, context=None):
+ conf = self.browse(cr, uid, ids[0], context)
+ dir_pool = self.pool.get('document.directory')
+ data_pool = self.pool.get('ir.model.data')
+ # Update the action for FTP browse.
+ aid = data_pool._get_id(cr, uid, 'document_ftp', 'action_document_browse')
+ aid = data_pool.browse(cr, uid, aid, context=context).res_id
+ self.pool.get('ir.actions.url').write(cr, uid, [aid], {'url': 'ftp://'+(conf.host or 'localhost:8021')+'/'})
+document_ftp_configuration()
diff --git a/addons/document_ftp/wizard/ftp_configuration_view.xml b/addons/document_ftp/wizard/ftp_configuration_view.xml
new file mode 100644
index 00000000000..df3aee360af
--- /dev/null
+++ b/addons/document_ftp/wizard/ftp_configuration_view.xml
@@ -0,0 +1,53 @@
+<openerp>
+ <data>
+ <record model="ir.actions.url" id="action_document_browse">
+ <field name="name">Browse Files</field>
+ <field name="url">ftp://localhost:8021/</field>
+ </record>
+
+
+
+ <record id="view_auto_config_form" model="ir.ui.view">
+ <field name="name">FTP Server Configuration</field>
+ <field name="model">document.ftp.configuration</field>
+ <field name="type">form</field>
+ <field name="inherit_id" ref="base.res_config_view_base"/>
+ <field name="arch" type="xml">
+ <data>
+ <form position="attributes">
+ <attribute name="string">FTP Server Configuration</attribute>
+ </form>
+ <separator string="title" position="attributes">
+ <attribute name="string">FTP Server Configuration</attribute>
+ </separator>
+ <xpath expr="//label[@string='description']" position="attributes">
+ <attribute name="string">Choose the address for the Document Management System's FTP server.</attribute>
+ </xpath>
+ <xpath expr='//separator[@string="vsep"]' position='attributes'>
+ <attribute name='rowspan'>12</attribute>
+ <attribute name='string'></attribute>
+ </xpath>
+ <group string="res_config_contents" position="replace">
+ <field name="host"/>
+ </group>
+ <xpath expr="//button[@name='action_skip']" position="replace"/>
+ </data>
+ </field>
+ </record>
+
+ <record id="action_config_auto_directory" model="ir.actions.act_window">
+ <field name="name">FTP Server Configuration</field>
+ <field name="type">ir.actions.act_window</field>
+ <field name="res_model">document.ftp.configuration</field>
+ <field name="view_id" ref="view_auto_config_form"/>
+ <field name="view_type">form</field>
+ <field name="view_mode">form</field>
+ <field name="target">new</field>
+ </record>
+
+ <record model="ir.actions.todo" id="config_auto_directory">
+ <field name="action_id" ref="action_config_auto_directory"/>
+ <field name="groups_id" eval="[(6,0,[ref('base.group_extended')])]"/>
+ </record>
+ </data>
+</openerp>