diff --git a/addons/document/document.py b/addons/document/document.py index 1a391ed4a29..b28b81af7d9 100644 --- a/addons/document/document.py +++ b/addons/document/document.py @@ -194,13 +194,6 @@ class node_class(object): path = self.path[1:] return path -class document_directory_node(osv.osv): - _inherit = 'process.node' - _columns = { - 'directory_id': fields.many2one('document.directory', 'Document directory', ondelete="set null"), - } -document_directory_node() - class document_directory(osv.osv): _name = 'document.directory' _description = 'Document directory' @@ -233,6 +226,25 @@ class document_directory(osv.osv): ('dirname_uniq', 'unique (name,parent_id,ressource_id,ressource_parent_type_id)', 'The directory name must be unique !') ] + def get_resource_path(self,cr,uid,res_model,res_id): + # to be need test + path=[] + def _parent(dir_id): + parent=self.browse(cr,uid,dir_id) + if parent.parent_id: + _parent(parent.parent_id.id) + else: + path.append(parent.name) + return path + model_ids=self.pool.get('ir.model').search(cr,uid,[('model','=',res_model)]) + directory_ids=self.search(cr,uid,[('ressource_type_id','=',model_ids[0]),('ressource_id','=',res_id)]) + if len(directory_ids): + path=parent(directory_ids[0]) + direc=self.browse(cr,uid,directory_ids)[0] + path.append(direc.name) + path.append(self.pool.get(direc.ressource_type_id.model).browse(cr,uid,res_id).name) + return "ftp://localhost:8021/"+cr.dbname+'/'.join(path) + return False def _check_duplication(self, cr, uid,vals): if 'name' in vals: where=" name='%s'"% (vals['name']) @@ -351,6 +363,13 @@ class document_directory(osv.osv): document_directory() +class document_directory_node(osv.osv): + _inherit = 'process.node' + _columns = { + 'directory_id': fields.many2one('document.directory', 'Document directory', ondelete="set null"), + } +document_directory_node() + class document_directory_content(osv.osv): _name = 'document.directory.content' _description = 'Directory Content' @@ -572,4 +591,4 @@ class document_file(osv.osv): except: pass return super(document_file, self).unlink(cr, uid, ids, context) -document_file() +document_file() diff --git a/addons/report_document/__init__.py b/addons/report_document/__init__.py new file mode 100644 index 00000000000..ca50266ac0c --- /dev/null +++ b/addons/report_document/__init__.py @@ -0,0 +1,4 @@ +# -*- encoding: utf-8 -*- +import report_document +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/addons/report_document/__terp__.py b/addons/report_document/__terp__.py new file mode 100644 index 00000000000..f0e19fe4de9 --- /dev/null +++ b/addons/report_document/__terp__.py @@ -0,0 +1,20 @@ +# -*- encoding: utf-8 -*- +{ + "name" : "Document Management - Reporting", + "version" : "1.0", + "author" : "Tiny", + "depends" : ["document"], + "category" : "Generic Modules/Document Management", + "description": """ + Reporting for the Document Management module: + * Files by my + * Files by all users + """, + "init_xml" : [], + "demo_xml" : [], + "update_xml" : ["report_document_view.xml"], + "active": False, + "installable": True + } +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/addons/report_document/report_document.py b/addons/report_document/report_document.py new file mode 100644 index 00000000000..1743f6921c7 --- /dev/null +++ b/addons/report_document/report_document.py @@ -0,0 +1,155 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved. +# +# $Id: sale.py 1005 2005-07-25 08:41:42Z nicoe $ +# +# 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 fields,osv +import time + + +class report_document_user(osv.osv): + _name = "report.document.user" + _description = "Files details by Users" + _auto = False + _columns = { + 'name': fields.date('Month', readonly=True), + 'month': fields.char('Month', size=24,readonly=True), + 'user_id':fields.integer('Owner', readonly=True), + 'user':fields.char('User',size=64,readonly=True), + 'file_title': fields.char('File Name',size=64,readonly=True), + 'directory': fields.char('Directory',size=64,readonly=True), + 'create_date': fields.datetime('Date Created', readonly=True), + 'change_date': fields.datetime('Modified Date', readonly=True), + 'file_size': fields.integer('File Size', readonly=True), + 'nbr':fields.integer('# of Files', readonly=True), + 'type':fields.char('Directory Type',size=64,readonly=True), + 'partner':fields.char('Partner',size=64,readonly=True), + } + def init(self, cr): + cr.execute(""" + create or replace view report_document_user as ( + select + min(f.id) as id, + f.user_id as user_id, + u.name as user, + count(*) as nbr, + to_char(f.create_date,'YYYY-MM')||'-'||'01' as name, + d.name as directory, + f.create_date as create_date, + f.file_size as file_size, + min(f.title) as file_title, + min(d.type) as type, + min(EXTRACT(MONTH FROM f.create_date)||'-'||substring(to_char(f.create_date,'YY-Month-DD') from 4 for 9)) as month, + f.write_date as change_date + from ir_attachment f + left join document_directory d on (f.parent_id=d.id and d.name<>'') + inner join res_users u on (f.user_id=u.id) + group by d.name,f.parent_id,d.type,f.create_date,f.user_id,f.file_size,u.name,d.type,f.write_date + ) + """) +report_document_user() + +class report_files_partenr(osv.osv): + _name = "report.files.partenr" + _description = "Files details by Partners" + _auto = False + _columns = { + 'name': fields.date('Month', readonly=True), + 'file_title': fields.char('File Name',size=64,readonly=True), + 'directory': fields.char('Directory',size=64,readonly=True), + 'create_date': fields.datetime('Date Created', readonly=True), + 'change_date': fields.datetime('Modified Date', readonly=True), + 'file_size': fields.integer('File Size', readonly=True), + 'nbr':fields.integer('# of Files', readonly=True), + 'type':fields.char('Directory Type',size=64,readonly=True), + 'partner':fields.char('Partner',size=64,readonly=True), + } + def init(self, cr): + cr.execute(""" + create or replace view report_files_partenr as ( + select min(f.id) as id,count(*) as nbr,min(to_char(f.create_date,'YYYY-MM')||'-'||'01') as name,min(f.title) as file_title,p.name as partner from ir_attachment f inner join res_partner p on (f.partner_id=p.id) group by p.name + ) + """) +report_files_partenr() + +class report_document_file(osv.osv): + _name = "report.document.file" + _description = "Files details by Directory" + _auto = False + _columns = { + 'file_size': fields.integer('File Size', readonly=True), + 'nbr':fields.integer('# of Files', readonly=True), + 'month': fields.char('Month', size=24,readonly=True), + } + _order = "month" + def init(self, cr): + cr.execute(""" + create or replace view report_document_file as ( + select min(f.id) as id,count(*) as nbr, + min(EXTRACT(MONTH FROM f.create_date)||'-'||substring(to_char(f.create_date,'YY-Month-DD') from 4 for 9)) as month, + sum(f.file_size) as file_size + from ir_attachment f + group by EXTRACT(MONTH FROM f.create_date) + ) + """) + +report_document_file() + +class report_document_wall(osv.osv): + _name = "report.document.wall" + _description = "Users that did not inserted documents since one month" + _auto = False + _columns = { + 'name': fields.date('Month', readonly=True), + 'user_id':fields.many2one('res.users', 'Owner',readonly=True), + 'user':fields.char('User',size=64,readonly=True), + 'month': fields.char('Month', size=24,readonly=True), + 'file_name':fields.char('Last Posted File Name',size=64,readonly=True), + 'last':fields.datetime('Last Posted Time', readonly=True), + } + + def init(self, cr): + cr.execute(""" + create or replace view report_document_wall as ( + select max(f.id) as id, + min(title) as file_name, + to_char(min(f.create_date),'YYYY-MM-DD HH24:MI:SS') as last, + f.user_id as user_id,f.user_id as user, + substring(to_char(f.create_date,'YY-Month-DD') from 4 for 9) as month + from ir_attachment f + where create_date in ( + select max(create_date) + from ir_attachment i + inner join res_users u on (i.user_id=u.id) + group by i.user_id) group by f.user_id,f.create_date + having (to_date(substring(CURRENT_DATE for 10),'YYYY-MM-DD') - to_date(substring(f.create_date for 10),'YYYY-MM-DD')) > 30 + ) + """) +report_document_wall() +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/addons/report_document/report_document_view.xml b/addons/report_document/report_document_view.xml new file mode 100644 index 00000000000..c0a67d101e4 --- /dev/null +++ b/addons/report_document/report_document_view.xml @@ -0,0 +1,288 @@ + + + + + + report.document.user.form + report.document.user + form + +
+ + + + + + + + +
+ + + + report.document.user.tree + report.document.user + tree + + + + + + + + + + + + + + + My files (This months) + report.document.user + form + tree + [('user_id','=',uid),('name','=',time.strftime('%Y-%m-01'))] + + + + + + + + + My files (All months) + report.document.user + form + tree,graph + [('user_id','=',uid)] + + + + + + + All Users files (This month) + report.document.user + form + tree,graph + [('name','=',time.strftime('%Y-%m-01'))] + + + + + + All Users files (All months) + report.document.user + form + tree + + + + + + + report.document.wall.form + report.document.wall + form + +
+ + + + + + +
+ + + + report.document.wall.tree + report.document.wall + tree + + + + + + + + + + + + Wall of Shame + report.document.wall + form + tree,form + + + + + + + + report.document.resource.graph + report.document.user + graph + + + + + + + + + + + + + + + + + + + + + + + Files by Resource Type + report.document.user + + form + tree + + + + + + report.document.user.graph + report.document.file + graph + + + + + + + + + + report.document.user.tree + report.document.file + tree + + + + + + + + + File Size by Month + report.document.file + + form + tree + + + + + + + report.file.month.graph + report.document.user + graph + + + + + + + + + + + + + report.file.month.tree + report.document.user + tree + + + + + + + + + + Files by Month + report.document.user + + form + tree + + + + + + + report.document.user.graph + report.document.user + graph + + + + + + + + + + Files By Users + report.document.user + + form + tree + + + + + + + view.files.partenr.graph + report.files.partenr + graph + + + + + + + + + + + view.files.partner.tree + report.files.partenr + tree + + + + + + + + + + Files Per Month + report.files.partenr + + form + tree + + + +
+