improved_document
bzr revid: fp@tinyerp.com-20081028083803-muzp8gr3l2er3sqf
This commit is contained in:
parent
29495c58ce
commit
31028bc1dd
|
@ -16,6 +16,7 @@
|
|||
"init_xml" : ["document_data.xml"],
|
||||
"update_xml" : [
|
||||
"document_view.xml",
|
||||
"document_data.xml",
|
||||
"security/document_security.xml",
|
||||
"security/ir.model.access.csv",
|
||||
],
|
||||
|
|
|
@ -77,14 +77,17 @@ class node_class(object):
|
|||
fobj = pool.get('ir.attachment')
|
||||
res2 = []
|
||||
where = []
|
||||
print '_FILE_GET', nodename
|
||||
if self.object2:
|
||||
where.append( ('res_model','=',self.object2._name) )
|
||||
where.append( ('res_id','=',self.object2.id) )
|
||||
for content in self.object.content_ids:
|
||||
for content in self.object.content_ids:
|
||||
if self.object2 or not content.include_name:
|
||||
if content.include_name:
|
||||
test_nodename = self.object2.name + (content.suffix or '') + (content.extension or '')
|
||||
else:
|
||||
test_nodename = (content.suffix or '') + (content.extension or '')
|
||||
print 'TESTING CONTENT', test_nodename
|
||||
if test_nodename.find('/'):
|
||||
test_nodename=test_nodename.replace('/', '_')
|
||||
path = self.path+'/'+test_nodename
|
||||
|
@ -128,10 +131,12 @@ class node_class(object):
|
|||
return res
|
||||
|
||||
def _child_get(self, nodename=False):
|
||||
print 'Getting Childs', nodename, self.type
|
||||
if self.type not in ('collection','database'):
|
||||
return []
|
||||
res = self.directory_list_for_child(nodename)
|
||||
result= map(lambda x: node_class(self.cr, self.uid, self.path+'/'+x.name, x, x.type=='directory' and self.object2 or False, root=self.root), res)
|
||||
print 'RESULT', result
|
||||
if self.type=='database':
|
||||
pool = pooler.get_pool(self.cr.dbname)
|
||||
fobj = pool.get('ir.attachment')
|
||||
|
@ -142,7 +147,9 @@ class node_class(object):
|
|||
|
||||
res = fobj.browse(self.cr, self.uid, file_ids, context=self.context)
|
||||
result +=map(lambda x: node_class(self.cr, self.uid, self.path+'/'+x.name, x, False, type='file', root=self.root), res)
|
||||
print 'DATABASE', result
|
||||
if self.type=='collection' and self.object.type=="ressource":
|
||||
print 'ICI'
|
||||
where = self.object.domain and eval(self.object.domain, {'active_id':self.root}) or []
|
||||
pool = pooler.get_pool(self.cr.dbname)
|
||||
obj = pool.get(self.object.ressource_type_id.model)
|
||||
|
@ -379,36 +386,41 @@ class document_directory_node(osv.osv):
|
|||
}
|
||||
document_directory_node()
|
||||
|
||||
class document_directory_content_type(osv.osv):
|
||||
_name = 'document.directory.content.type'
|
||||
_description = 'Directory Content Type'
|
||||
_columns = {
|
||||
'name': fields.char('Content Type', size=64, required=True),
|
||||
'code': fields.char('Extension', size=4),
|
||||
'active': fields.boolean('Active'),
|
||||
}
|
||||
_defaults = {
|
||||
'active': lambda *args: 1
|
||||
}
|
||||
document_directory_content_type()
|
||||
|
||||
class document_directory_content(osv.osv):
|
||||
_name = 'document.directory.content'
|
||||
_description = 'Directory Content'
|
||||
_order = "sequence"
|
||||
def _extension_get(self, cr, uid, context={}):
|
||||
cr.execute('select code,name from document_directory_content_type where active')
|
||||
res = cr.fetchall()
|
||||
return res
|
||||
_columns = {
|
||||
'name': fields.char('Content Name', size=64, required=True),
|
||||
'sequence': fields.integer('Sequence', size=16),
|
||||
'suffix': fields.char('Suffix', size=16),
|
||||
'report_id': fields.many2one('ir.actions.report.xml', 'Report', required=True),
|
||||
'extension': fields.selection([('.pdf','PDF Report'),('.ics','ICS Calendar')], 'Report Type', required=True),
|
||||
'report_id': fields.many2one('ir.actions.report.xml', 'Report'),
|
||||
'extension': fields.selection(_extension_get, 'Report Type', required=True, size=4),
|
||||
'include_name': fields.boolean('Include Record Name', help="Check if you cant that the name of the file start by the record name."),
|
||||
'directory_id': fields.many2one('document.directory', 'Directory'),
|
||||
'ics_object_id': fields.many2one('ir.model', 'Object'),
|
||||
'ics_domain': fields.char('Domain', size=64)
|
||||
}
|
||||
_defaults = {
|
||||
'extension': lambda *args: '.pdf',
|
||||
'sequence': lambda *args: 1,
|
||||
'include_name': lambda *args: 1,
|
||||
}
|
||||
def process_read_ics(self, cr, uid, node, context={}):
|
||||
import vobject
|
||||
obj_class = self.pool.get(node.ics_object_id.name)
|
||||
ids = obj_class.search(cr, uid, node.ics_domain, context)
|
||||
cal = vobject.iCalendar()
|
||||
for obj in obj_class.browse(cr, uid, ids, context):
|
||||
cal.add('vevent')
|
||||
cal.vevent.add('summary').value = "This is a note"
|
||||
return cal.serialize()
|
||||
|
||||
def process_read_pdf(self, cr, uid, node, context={}):
|
||||
report = self.pool.get('ir.actions.report.xml').browse(cr, uid, node.report_id.id)
|
||||
srv = netsvc.LocalService('report.'+report.report_name)
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data noupdate="1">
|
||||
<data>
|
||||
|
||||
<record model="document.directory.content.type" id="pdf">
|
||||
<field name="code">.pdf</field>
|
||||
<field name="name">PDF Report</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Directories">
|
||||
<notebook>
|
||||
<field name="name" select="1" colspan="4"/>
|
||||
<field name="user_id"/>
|
||||
<field name="parent_id"/>
|
||||
<notebook colspan="4">
|
||||
<page string="Definition">
|
||||
<field name="name" select="1" colspan="4"/>
|
||||
<field name="user_id"/>
|
||||
<field name="parent_id"/>
|
||||
<separator string="Directory Type" colspan="4"/>
|
||||
<field name="type"/>
|
||||
<field name="ressource_type_id" on_change="onchange_content_id(ressource_type_id)"/>
|
||||
|
@ -29,12 +29,9 @@
|
|||
<field name="sequence"/>
|
||||
<field name="suffix"/>
|
||||
<field name="extension"/>
|
||||
<field name="include_name"/>
|
||||
<separator string="PDF Report" colspan="4"/>
|
||||
<field name="report_id" domain="[('model_id','=',parent.ressource_type_id)]"/>
|
||||
<separator string="ICS Calendar" colspan="4"/>
|
||||
<field name="include_name"/>
|
||||
<field name="ics_object_id"/>
|
||||
<field name="ics_domain"/>
|
||||
</form>
|
||||
<tree string="Contents">
|
||||
<field name="sequence" string="Seq."/>
|
||||
|
|
|
@ -205,7 +205,7 @@ class abstracted_fs:
|
|||
cr = node.cr
|
||||
uid = node.uid
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
return getattr(pool.get('document.directory.content'), 'process_read_'+node.extension[1:])(cr, uid, node)
|
||||
return getattr(pool.get('document.directory.content'), 'process_read_'+node.content.extension[1:])(cr, uid, node)
|
||||
else:
|
||||
raise OSError(1, 'Operation not permited.')
|
||||
|
||||
|
|
|
@ -7,3 +7,5 @@
|
|||
"access_document_directory_content_group_system","document.directory.content group system","model_document_directory_content","base.group_system",1,1,1,1
|
||||
"access_document_configuation_wizard","document.configuration.wizard document manager","model_document_configuration_wizard","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_directory_content_type_group_document_manager","document.directory.content.type document manager","model_document_directory_content_type","group_document_manager",1,1,1,1
|
||||
"access_document_directory_content_type_group_system","document.directory.content.type group system","model_document_directory_content_type","base.group_user",1,0,0,0
|
||||
|
|
|
|
@ -0,0 +1,29 @@
|
|||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
|
||||
# Fabien Pinckaers <fp@tiny.Be>
|
||||
#
|
||||
# WARNING: This program as such is intended to be used by professional
|
||||
# programmers who take the whole responsability of assessing all potential
|
||||
# consequences resulting from its eventual inadequacies and bugs
|
||||
# End users who are looking for a ready-to-use solution with commercial
|
||||
# garantees and support are strongly adviced to contract a Free Software
|
||||
# Service Company
|
||||
#
|
||||
# This program is Free Software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import document
|
|
@ -0,0 +1,19 @@
|
|||
#
|
||||
# Use the custom module to put your specific code in a separate module.
|
||||
#
|
||||
{
|
||||
"name" : "Suport for iCal based on Document Management System",
|
||||
"version" : "1.0",
|
||||
"author" : "Tiny",
|
||||
"category" : "Generic Modules/Others",
|
||||
"website": "http://www.tinyerp.com",
|
||||
"description": """Allows to synchronize calendars with others applications.""",
|
||||
"depends" : ["document"],
|
||||
"init_xml" : ["document_data.xml"],
|
||||
"update_xml" : [
|
||||
"document_view.xml",
|
||||
],
|
||||
"demo_xml" : [],
|
||||
"active": False,
|
||||
"installable": True
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
# WARNING: This program as such is intended to be used by professional
|
||||
# programmers who take the whole responsability of assessing all potential
|
||||
# consequences resulting from its eventual inadequacies and bugs
|
||||
# End users who are looking for a ready-to-use solution with commercial
|
||||
# garantees and support are strongly adviced to contract a Free Software
|
||||
# Service Company
|
||||
#
|
||||
# This program is Free Software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import osv, fields
|
||||
from osv.orm import except_orm
|
||||
import os
|
||||
import StringIO
|
||||
import base64
|
||||
|
||||
ICS_TAGS = [
|
||||
'summary'
|
||||
]
|
||||
|
||||
class document_directory_ics_fields(osv.osv):
|
||||
_name = 'document.directory.ics.fields'
|
||||
_columns = {
|
||||
'field_ids': fields.many2one('ir.model.fields', 'Open ERP Field', required=True),
|
||||
'name': fields.selection(map(lambda x: (x,x), ICS_TAGS),'ICS Value', required=True),
|
||||
}
|
||||
document_directory_ics_fields()
|
||||
|
||||
class document_directory_content(osv.osv):
|
||||
_inherit = 'document.directory.content'
|
||||
_columns = {
|
||||
'ics_object_id': fields.many2one('ir.model', 'Object'),
|
||||
'ics_domain': fields.char('Domain', size=64),
|
||||
'ics_field_ids': fields.one2many('document.directory.ics.fields', 'content_id', 'Fields Mapping')
|
||||
}
|
||||
_defaults = {
|
||||
'ics_domain': lambda *args: '[]'
|
||||
}
|
||||
def process_read_ics(self, cr, uid, node, context={}):
|
||||
print 'READ ICS'
|
||||
import vobject
|
||||
obj_class = self.pool.get(node.content.ics_object_id.model)
|
||||
# Can be improved to use context and active_id !
|
||||
domain = eval(node.content.ics_domain)
|
||||
ids = obj_class.search(cr, uid, domain, context)
|
||||
cal = vobject.iCalendar()
|
||||
for obj in obj_class.browse(cr, uid, ids, context):
|
||||
cal.add('vevent')
|
||||
cal.vevent.add('summary').value = "This is a note"
|
||||
break
|
||||
s= StringIO.StringIO(cal.serialize())
|
||||
s.name = node
|
||||
return s
|
||||
|
||||
document_directory_content()
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record model="document.directory.content.type" id="ics">
|
||||
<field name="code">.ics</field>
|
||||
<field name="name">ICS Calendar</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -0,0 +1,25 @@
|
|||
<openerp>
|
||||
<data>
|
||||
|
||||
<record model="ir.ui.view" id="view_document_directory_form">
|
||||
<field name="name">document.directory</field>
|
||||
<field name="model">document.directory</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="document.view_document_directory_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="report_id" position="after">
|
||||
<separator string="ICS Calendar" colspan="4"/>
|
||||
<field name="ics_object_id"/>
|
||||
<field name="ics_domain"/>
|
||||
<field name="ics_field_ids" colspan="4">
|
||||
<tree string="ICS Mapping" editable="bottom">
|
||||
<field name="name"/>
|
||||
<field name="field_id" domain="[('model_id','=',ics_object_id)]"/>
|
||||
</tree>
|
||||
</field>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
Loading…
Reference in New Issue