diff --git a/addons/document/__terp__.py b/addons/document/__terp__.py
index 8c43c21e633..847649f2523 100644
--- a/addons/document/__terp__.py
+++ b/addons/document/__terp__.py
@@ -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",
],
diff --git a/addons/document/document.py b/addons/document/document.py
index 8637e3bc1db..4471cb9e60a 100644
--- a/addons/document/document.py
+++ b/addons/document/document.py
@@ -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)
diff --git a/addons/document/document_data.xml b/addons/document/document_data.xml
index 9953d07dd92..33c6f80763a 100644
--- a/addons/document/document_data.xml
+++ b/addons/document/document_data.xml
@@ -1,6 +1,11 @@
-
+
+
+
+ .pdf
+ PDF Report
+
diff --git a/addons/document/document_view.xml b/addons/document/document_view.xml
index cd7689d4e9a..e9d53cddae9 100644
--- a/addons/document/document_view.xml
+++ b/addons/document/document_view.xml
@@ -8,11 +8,11 @@
form
diff --git a/addons/document/ftpserver/abstracted_fs.py b/addons/document/ftpserver/abstracted_fs.py
index 9741c5a6a25..b774ea94c17 100644
--- a/addons/document/ftpserver/abstracted_fs.py
+++ b/addons/document/ftpserver/abstracted_fs.py
@@ -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.')
diff --git a/addons/document/security/ir.model.access.csv b/addons/document/security/ir.model.access.csv
index dfe882e49d8..889ec8781f6 100644
--- a/addons/document/security/ir.model.access.csv
+++ b/addons/document/security/ir.model.access.csv
@@ -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
diff --git a/addons/document_ics/__init__.py b/addons/document_ics/__init__.py
new file mode 100644
index 00000000000..e21c95aefc5
--- /dev/null
+++ b/addons/document_ics/__init__.py
@@ -0,0 +1,29 @@
+##############################################################################
+#
+# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
+# Fabien Pinckaers
+#
+# 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
diff --git a/addons/document_ics/__terp__.py b/addons/document_ics/__terp__.py
new file mode 100644
index 00000000000..72aa2589a02
--- /dev/null
+++ b/addons/document_ics/__terp__.py
@@ -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
+}
diff --git a/addons/document_ics/document.py b/addons/document_ics/document.py
new file mode 100644
index 00000000000..e7874945194
--- /dev/null
+++ b/addons/document_ics/document.py
@@ -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()
+
diff --git a/addons/document_ics/document_data.xml b/addons/document_ics/document_data.xml
new file mode 100644
index 00000000000..5e2873aee6f
--- /dev/null
+++ b/addons/document_ics/document_data.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+ .ics
+ ICS Calendar
+
+
+
+
diff --git a/addons/document_ics/document_view.xml b/addons/document_ics/document_view.xml
new file mode 100644
index 00000000000..6af7a734a21
--- /dev/null
+++ b/addons/document_ics/document_view.xml
@@ -0,0 +1,25 @@
+
+
+
+
+ document.directory
+ document.directory
+ form
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+