[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
This commit is contained in:
parent
666c9db5f7
commit
02a17546b8
|
@ -27,5 +27,6 @@ import directory_content
|
|||
import directory_report
|
||||
import document
|
||||
import report
|
||||
import wizard
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
'update_xml': [
|
||||
'document_view.xml',
|
||||
'document_data.xml',
|
||||
'wizard/document_configuration_view.xml',
|
||||
'security/document_security.xml',
|
||||
'security/ir.model.access.csv',
|
||||
'report/document_report_view.xml',
|
||||
|
|
|
@ -112,7 +112,7 @@ class document_directory(osv.osv):
|
|||
while d2 and d2.parent_id:
|
||||
s = d2.name + (s and ('/' + s) or '')
|
||||
d2 = d2.parent_id
|
||||
res.append((d.id, s))
|
||||
res.append((d.id, s or d.name))
|
||||
return res
|
||||
|
||||
def get_full_path(self, cr, uid, dir_id, context=None):
|
||||
|
|
|
@ -193,10 +193,7 @@
|
|||
<group col="2" colspan="2" attrs="{'invisible':[('type','=','binary')]}">
|
||||
<field name="url" widget="url"/>
|
||||
</group>
|
||||
|
||||
</group>
|
||||
|
||||
|
||||
<group col="2" colspan="2">
|
||||
<separator string="Relation" colspan="2"/>
|
||||
<field name="res_name" readonly="1"/>
|
||||
|
@ -219,7 +216,9 @@
|
|||
<page string="Security">
|
||||
<field name="group_ids" colspan="4" nolabel="1"/>
|
||||
</page>
|
||||
|
||||
<page string="Indexed Content" groups="base.group_extended">
|
||||
<field name="index_content" colspan="4" nolabel="1"/>
|
||||
</page>
|
||||
<page string="Notes">
|
||||
<field colspan="4" name="description" nolabel="1"/>
|
||||
</page>
|
||||
|
|
|
@ -19,3 +19,5 @@
|
|||
"access_report_document_file_group_system","report.document.file group system","model_report_document_file","base.group_system",1,0,0,0
|
||||
"access_report_document_wall_group_document_manager","report.document.wall document manager","model_report_document_wall","document.group_document_manager",1,0,0,0
|
||||
"access_report_document_wall_group_system","report.document.wall group system","model_report_document_wall","base.group_system",1,0,0,0
|
||||
"access_document_configuation","document.configuration document manager","model_document_configuration","document.group_document_manager",1,1,1,1
|
||||
"access_document_configuation_system","document.configuration group system","model_document_configuration","base.group_system",1,1,1,1
|
||||
|
|
|
|
@ -19,10 +19,11 @@
|
|||
#
|
||||
##############################################################################
|
||||
|
||||
from content_index import indexer, cntIndex
|
||||
from subprocess import Popen, PIPE
|
||||
import StringIO
|
||||
import odt2txt
|
||||
from subprocess import Popen, PIPE
|
||||
from content_index import indexer, cntIndex
|
||||
import sys, zipfile, xml.dom.minidom
|
||||
|
||||
def _to_unicode(s):
|
||||
try:
|
||||
|
@ -36,6 +37,15 @@ def _to_unicode(s):
|
|||
except UnicodeError:
|
||||
return s
|
||||
|
||||
def textToString(element) :
|
||||
buffer = u""
|
||||
for node in element.childNodes :
|
||||
if node.nodeType == xml.dom.Node.TEXT_NODE :
|
||||
buffer += node.nodeValue
|
||||
elif node.nodeType == xml.dom.Node.ELEMENT_NODE :
|
||||
buffer += textToString(node)
|
||||
return buffer
|
||||
|
||||
class TxtIndex(indexer):
|
||||
def _getMimeTypes(self):
|
||||
return ['text/plain','text/html','text/diff','text/xml', 'text/*',
|
||||
|
@ -44,7 +54,7 @@ class TxtIndex(indexer):
|
|||
def _getExtensions(self):
|
||||
return ['.txt', '.py']
|
||||
|
||||
def _doIndexContent(self, content):
|
||||
def _doIndexContent(self,content):
|
||||
return content
|
||||
|
||||
cntIndex.register(TxtIndex())
|
||||
|
@ -56,15 +66,24 @@ class PptxIndex(indexer):
|
|||
def _getExtensions(self):
|
||||
return ['.pptx']
|
||||
|
||||
def _doIndexFile(self, fname):
|
||||
# pptx2txt.pl package not support in windows platform.
|
||||
# Download pptx2txt package from http://sourceforge.net/projects/pptx2txt/" link.
|
||||
# To install this tool, just copy pptx2txt.pl to appropriate place (e.g. /usr/bin directory)
|
||||
fp = Popen(['pptx2txt.pl', fname], shell=False, stdout=PIPE).stdout
|
||||
fp.read()
|
||||
file_obj = open(str(fname + ".txt"), "r")
|
||||
data = file_obj.read()
|
||||
return _to_unicode(data)
|
||||
def _doIndexFile(self,fname):
|
||||
def toString () :
|
||||
""" Converts the document to a string. """
|
||||
buffer = u""
|
||||
for val in ["a:t"]:
|
||||
for paragraph in content.getElementsByTagName(val) :
|
||||
buffer += textToString(paragraph) + "\n"
|
||||
return buffer
|
||||
|
||||
data = []
|
||||
zip = zipfile.ZipFile(fname)
|
||||
files = filter(lambda x: x.startswith('ppt/slides/slide'), zip.namelist())
|
||||
for i in range(1, len(files) + 1):
|
||||
content = xml.dom.minidom.parseString(zip.read('ppt/slides/slide%s.xml' % str(i)))
|
||||
res = toString().encode('ascii','replace')
|
||||
data.append(res)
|
||||
|
||||
return _to_unicode('\n'.join(data))
|
||||
|
||||
cntIndex.register(PptxIndex())
|
||||
|
||||
|
@ -76,33 +95,60 @@ class DocIndex(indexer):
|
|||
return ['.doc']
|
||||
|
||||
def _doIndexFile(self,fname):
|
||||
fp = Popen(['antiword', fname], shell=False, stdout=PIPE).stdout
|
||||
return _to_unicode( fp.read())
|
||||
#fp = Popen(['antiword', fname], shell=False, stdout=PIPE).stdout
|
||||
return _to_unicode( 'None')
|
||||
|
||||
cntIndex.register(DocIndex())
|
||||
|
||||
class DocxIndex(indexer):
|
||||
def _getMimeTypes(self):
|
||||
return [ 'application/vnd.openxmlformats-officedocument.wordprocessingml.document']
|
||||
|
||||
|
||||
def _getExtensions(self):
|
||||
return ['.docx']
|
||||
|
||||
def _doIndexFile(self, fname):
|
||||
# docx2txt.pl package not support in windows platform.
|
||||
# Download docx2txt package from "http://sourceforge.net/projects/docx2txt/" link.
|
||||
# In case, you don't want to use Makefile for installation, you can follow these steps for manual installation.
|
||||
# Copy docx2txt.pl, docx2txt.sh and docx2txt.config to appropriate place (e.g. /usr/bin directory) . used following command.
|
||||
# --> cp docx2txt.pl docx2txt.sh docx2txt.config /usr/bin/
|
||||
def _doIndexFile(self,fname):
|
||||
zip = zipfile.ZipFile(fname)
|
||||
content = xml.dom.minidom.parseString(zip.read("word/document.xml"))
|
||||
def toString () :
|
||||
""" Converts the document to a string. """
|
||||
buffer = u""
|
||||
for val in ["w:p", "w:h", "text:list"]:
|
||||
for paragraph in content.getElementsByTagName(val) :
|
||||
buffer += textToString(paragraph) + "\n"
|
||||
return buffer
|
||||
|
||||
fp = Popen(['docx2txt.pl', fname], shell=False, stdout=PIPE).stdout
|
||||
fp.read()
|
||||
file_obj = open(str(fname + ".txt"), "r")
|
||||
data = file_obj.read()
|
||||
return _to_unicode(data)
|
||||
res = toString().encode('ascii','replace')
|
||||
|
||||
return _to_unicode(res)
|
||||
|
||||
cntIndex.register(DocxIndex())
|
||||
|
||||
|
||||
class XlsxIndex(indexer):
|
||||
def _getMimeTypes(self):
|
||||
return [ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']
|
||||
|
||||
def _getExtensions(self):
|
||||
return ['.xlsx']
|
||||
|
||||
def _doIndexFile(self,fname):
|
||||
zip = zipfile.ZipFile(fname)
|
||||
content = xml.dom.minidom.parseString(zip.read("xl/sharedStrings.xml"))
|
||||
def toString () :
|
||||
""" Converts the document to a string. """
|
||||
buffer = u""
|
||||
for val in ["t"]:
|
||||
for paragraph in content.getElementsByTagName(val) :
|
||||
buffer += textToString(paragraph) + "\n"
|
||||
return buffer
|
||||
|
||||
res = toString().encode('ascii','replace')
|
||||
|
||||
return _to_unicode(res)
|
||||
|
||||
cntIndex.register(XlsxIndex())
|
||||
|
||||
class PdfIndex(indexer):
|
||||
def _getMimeTypes(self):
|
||||
return [ 'application/pdf']
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
# -*- 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 document_configuration
|
|
@ -0,0 +1,120 @@
|
|||
# -*- 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
|
||||
class document_configuration(osv.osv_memory):
|
||||
|
||||
_name='document.configuration'
|
||||
_description = 'Auto Directory Configuration'
|
||||
_inherit = 'res.config'
|
||||
|
||||
_columns = {
|
||||
'sale_order' : fields.boolean('Sale Order', help="Auto directory configuration for Sale Orders and Quotation with report."),
|
||||
'product' : fields.boolean('Product', help="Auto directory configuration for Products."),
|
||||
'project': fields.boolean('Project', help="Auto directory configuration for Projects."),
|
||||
}
|
||||
|
||||
|
||||
def execute(self, cr, uid, ids, context=None):
|
||||
conf_id = ids and ids[0] or False
|
||||
conf = self.browse(cr, uid, conf_id, context)
|
||||
dir_pool = self.pool.get('document.directory')
|
||||
data_pool = self.pool.get('ir.model.data')
|
||||
model_pool = self.pool.get('ir.model')
|
||||
content_pool = self.pool.get('document.directory.content')
|
||||
if conf.sale_order and self.pool.get('sale.order'):
|
||||
# Sale order
|
||||
dir_data_id = data_pool._get_id(cr, uid, 'document', 'dir_sale_order_all')
|
||||
if dir_data_id:
|
||||
sale_dir_id = data_pool.browse(cr, uid, dir_data_id, context=context).res_id
|
||||
else:
|
||||
sale_dir_id = data_pool.create(cr, uid, {'name': 'Sale Orders'})
|
||||
mid = model_pool.search(cr, uid, [('model','=','sale.order')])
|
||||
dir_pool.write(cr, uid, [sale_dir_id], {
|
||||
'type':'ressource',
|
||||
'ressource_type_id': mid[0],
|
||||
'domain': '[]',
|
||||
})
|
||||
# Qutation
|
||||
dir_data_id = data_pool._get_id(cr, uid, 'document', 'dir_sale_order_quote')
|
||||
if dir_data_id:
|
||||
quta_dir_id = data_pool.browse(cr, uid, dir_data_id, context=context).res_id
|
||||
else:
|
||||
quta_dir_id = data_pool.create(cr, uid, {'name': 'Sale Quotations'})
|
||||
|
||||
dir_pool.write(cr, uid, [quta_dir_id], {
|
||||
'type':'ressource',
|
||||
'ressource_type_id': mid[0],
|
||||
'domain': "[('state','=','draft')]",
|
||||
})
|
||||
# Sale Order Report
|
||||
order_report_data_id = data_pool._get_id(cr, uid, 'sale', 'report_sale_order')
|
||||
if order_report_data_id:
|
||||
order_report_id = data_pool.browse(cr, uid, order_report_data_id, context=context).res_id
|
||||
|
||||
content_pool.create(cr, uid, {
|
||||
'name': "Print Order",
|
||||
'suffix': "_print",
|
||||
'report_id': order_report_id,
|
||||
'extension': '.pdf',
|
||||
'include_name': 1,
|
||||
'directory_id': sale_dir_id,
|
||||
})
|
||||
|
||||
content_pool.create(cr, uid, {
|
||||
'name': "Print Qutation",
|
||||
'suffix': "_print",
|
||||
'report_id': order_report_id,
|
||||
'extension': '.pdf',
|
||||
'include_name': 1,
|
||||
'directory_id': quta_dir_id,
|
||||
})
|
||||
|
||||
|
||||
if conf.product and self.pool.get('product.product'):
|
||||
# Product
|
||||
dir_data_id = data_pool._get_id(cr, uid, 'document', 'dir_product')
|
||||
if dir_data_id:
|
||||
product_dir_id = data_pool.browse(cr, uid, dir_data_id, context=context).res_id
|
||||
else:
|
||||
product_dir_id = data_pool.create(cr, uid, {'name': 'Products'})
|
||||
|
||||
mid = model_pool.search(cr, uid, [('model','=','product.product')])
|
||||
dir_pool.write(cr, uid, [product_dir_id], {
|
||||
'type':'ressource',
|
||||
'ressource_type_id': mid[0],
|
||||
})
|
||||
|
||||
if conf.project and self.pool.get('account.analytic.account'):
|
||||
# Project
|
||||
dir_data_id = data_pool._get_id(cr, uid, 'document', 'dir_project')
|
||||
if dir_data_id:
|
||||
project_dir_id = data_pool.browse(cr, uid, dir_data_id, context=context).res_id
|
||||
else:
|
||||
project_dir_id = data_pool.create(cr, uid, {'name': 'Projects'})
|
||||
|
||||
mid = model_pool.search(cr, uid, [('model','=','account.analytic.account')])
|
||||
dir_pool.write(cr, uid, [project_dir_id], {
|
||||
'type':'ressource',
|
||||
'ressource_type_id': mid[0],
|
||||
'domain': '[]',
|
||||
'ressource_tree': 1
|
||||
})
|
||||
document_configuration()
|
|
@ -0,0 +1,50 @@
|
|||
<openerp>
|
||||
<data>
|
||||
<record id="view_auto_config_form" model="ir.ui.view">
|
||||
<field name="name">Auto Configure Directory</field>
|
||||
<field name="model">document.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">Auto Configure</attribute>
|
||||
</form>
|
||||
<separator string="title" position="attributes">
|
||||
<attribute name="string">Resource Directory Configuration </attribute>
|
||||
</separator>
|
||||
<xpath expr="//label[@string='description']" position="attributes">
|
||||
<attribute name="string">Choose the following Resouces to auto directory configuration.</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">
|
||||
<group col="6" colspan="4">
|
||||
<field name="sale_order"/>
|
||||
<field name="product"/>
|
||||
<field name="project"/>
|
||||
</group>
|
||||
</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">Auto Configure Directory</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">document.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>
|
|
@ -18,7 +18,7 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
import doc_conf_wizard
|
||||
import ftpserver
|
||||
import wizard
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -33,7 +33,8 @@
|
|||
'depends': ['base', 'document'],
|
||||
'init_xml': [],
|
||||
'update_xml': [
|
||||
'document_ftp_view.xml',
|
||||
'wizard/ftp_configuration_view.xml',
|
||||
'wizard/ftp_browse_view.xml',
|
||||
'security/ir.model.access.csv'
|
||||
],
|
||||
'demo_xml': [],
|
||||
|
|
|
@ -1,117 +0,0 @@
|
|||
# -*- 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_configuration_wizard(osv.osv_memory):
|
||||
|
||||
_name='document.configuration.wizard'
|
||||
_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)
|
||||
obj=self.pool.get('document.directory')
|
||||
objid=self.pool.get('ir.model.data')
|
||||
|
||||
if self.pool.get('sale.order'):
|
||||
id = objid._get_id(cr, uid, 'document', 'dir_sale_order_all')
|
||||
id = objid.browse(cr, uid, id, context=context).res_id
|
||||
mid = self.pool.get('ir.model').search(cr, uid, [('model','=','sale.order')])
|
||||
obj.write(cr, uid, [id], {
|
||||
'type':'ressource',
|
||||
'ressource_type_id': mid[0],
|
||||
'domain': '[]',
|
||||
})
|
||||
aid = objid._get_id(cr, uid, 'sale', 'report_sale_order')
|
||||
aid = objid.browse(cr, uid, aid, context=context).res_id
|
||||
|
||||
self.pool.get('document.directory.content').create(cr, uid, {
|
||||
'name': "Print Order",
|
||||
'suffix': "_print",
|
||||
'report_id': aid,
|
||||
'extension': '.pdf',
|
||||
'include_name': 1,
|
||||
'directory_id': id,
|
||||
})
|
||||
id = objid._get_id(cr, uid, 'document', 'dir_sale_order_quote')
|
||||
id = objid.browse(cr, uid, id, context=context).res_id
|
||||
obj.write(cr, uid, [id], {
|
||||
'type':'ressource',
|
||||
'ressource_type_id': mid[0],
|
||||
'domain': "[('state','=','draft')]",
|
||||
})
|
||||
|
||||
if self.pool.get('product.product'):
|
||||
id = objid._get_id(cr, uid, 'document', 'dir_product')
|
||||
id = objid.browse(cr, uid, id, context=context).res_id
|
||||
mid = self.pool.get('ir.model').search(cr, uid, [('model','=','product.product')])
|
||||
obj.write(cr, uid, [id], {
|
||||
'type':'ressource',
|
||||
'ressource_type_id': mid[0],
|
||||
})
|
||||
|
||||
if self.pool.get('stock.location'):
|
||||
aid = objid._get_id(cr, uid, 'stock', 'report_product_history')
|
||||
aid = objid.browse(cr, uid, aid, context=context).res_id
|
||||
|
||||
self.pool.get('document.directory.content').create(cr, uid, {
|
||||
'name': "Product Stock",
|
||||
'suffix': "_stock_forecast",
|
||||
'report_id': aid,
|
||||
'extension': '.pdf',
|
||||
'include_name': 1,
|
||||
'directory_id': id,
|
||||
})
|
||||
|
||||
if self.pool.get('account.analytic.account'):
|
||||
id = objid._get_id(cr, uid, 'document', 'dir_project')
|
||||
id = objid.browse(cr, uid, id, context=context).res_id
|
||||
mid = self.pool.get('ir.model').search(cr, uid, [('model','=','account.analytic.account')])
|
||||
obj.write(cr, uid, [id], {
|
||||
'type':'ressource',
|
||||
'ressource_type_id': mid[0],
|
||||
'domain': '[]',
|
||||
'ressource_tree': 1
|
||||
})
|
||||
|
||||
# Update the action for FTP browse.
|
||||
aid = objid._get_id(cr, uid, 'document_ftp', 'action_document_browse')
|
||||
aid = objid.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_configuration_wizard()
|
|
@ -1,3 +1,6 @@
|
|||
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
|
||||
"access_document_configuation_wizard","document.configuration.wizard document manager","model_document_configuration_wizard","document.group_document_manager",1,1,1,1
|
||||
"access_document_configuation_wizard_sytem","document.configuration.wizard group system","model_document_configuration_wizard","base.group_system",1,1,1,1
|
||||
"access_document_ftp_browse","document.ftp.browse document manager","model_document_ftp_browse","document.group_document_manager",1,1,1,1
|
||||
"access_document_ftp_browse","document.ftp.browse group system","model_document_ftp_browse","base.group_system",1,1,1,1
|
||||
"access_document_ftp_configuation","document.ftp.configuration document manager","model_document_ftp_configuration","document.group_document_manager",1,1,1,1
|
||||
"access_document_ftp_configuation_system","document.ftp.configuration group system","model_document_ftp_configuration","base.group_system",1,1,1,1
|
||||
|
||||
|
|
|
|
@ -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:
|
|
@ -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()
|
||||
|
|
@ -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>
|
|
@ -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()
|
|
@ -3,26 +3,19 @@
|
|||
<record model="ir.actions.url" id="action_document_browse">
|
||||
<field name="name">Browse Files</field>
|
||||
<field name="url">ftp://localhost:8021/</field>
|
||||
</record>
|
||||
<menuitem
|
||||
name="Shared Repository (FTP)"
|
||||
action="action_document_browse"
|
||||
id="menu_document_browse"
|
||||
type="url"
|
||||
icon="STOCK_EXECUTE"
|
||||
parent="document.menu_document_doc" sequence="1"/>
|
||||
</record>
|
||||
|
||||
|
||||
|
||||
<record id="view_auto_config_form" model="ir.ui.view">
|
||||
<field name="name">Auto Configure Directory</field>
|
||||
<field name="model">document.configuration.wizard</field>
|
||||
<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">Auto Configure</attribute>
|
||||
<attribute name="string">FTP Server Configuration</attribute>
|
||||
</form>
|
||||
<separator string="title" position="attributes">
|
||||
<attribute name="string">FTP Server Configuration</attribute>
|
||||
|
@ -43,9 +36,9 @@
|
|||
</record>
|
||||
|
||||
<record id="action_config_auto_directory" model="ir.actions.act_window">
|
||||
<field name="name">Auto Configure Directory</field>
|
||||
<field name="name">FTP Server Configuration</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">document.configuration.wizard</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>
|
Loading…
Reference in New Issue