1 # -*- encoding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 ##############################################################################
23 # This program is distributed in the hope that it will be useful,
24 # but WITHOUT ANY WARRANTY; without even the implied warranty of
25 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 # GNU General Public License for more details.
28 # You should have received a copy of the GNU General Public License
29 # along with this program; if not, write to the Free Software
30 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32 ##############################################################################
34 from osv import fields,osv
38 class report_document_user(osv.osv):
39 _name = "report.document.user"
40 _description = "Files details by Users"
43 'name': fields.date('Month', readonly=True),
44 'month': fields.char('Month', size=24,readonly=True),
45 'user_id':fields.integer('Owner', readonly=True),
46 'user':fields.char('User',size=64,readonly=True),
47 'file_title': fields.char('File Name',size=64,readonly=True),
48 'directory': fields.char('Directory',size=64,readonly=True),
49 'create_date': fields.datetime('Date Created', readonly=True),
50 'change_date': fields.datetime('Modified Date', readonly=True),
51 'file_size': fields.integer('File Size', readonly=True),
52 'nbr':fields.integer('# of Files', readonly=True),
53 'type':fields.char('Directory Type',size=64,readonly=True),
54 'partner':fields.char('Partner',size=64,readonly=True),
58 create or replace view report_document_user as (
64 to_char(f.create_date,'YYYY-MM')||'-'||'01' as name,
66 f.create_date as create_date,
67 f.file_size as file_size,
68 min(f.title) as file_title,
70 min(EXTRACT(MONTH FROM f.create_date)||'-'||to_char(f.create_date,'Month')) as month,
71 f.write_date as change_date
73 left join document_directory d on (f.parent_id=d.id and d.name<>'')
74 inner join res_users u on (f.user_id=u.id)
75 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
78 report_document_user()
80 class report_files_partner(osv.osv):
81 _name = "report.files.partner"
82 _description = "Files details by Partners"
85 'name': fields.date('Month', readonly=True),
86 'file_title': fields.char('File Name',size=64,readonly=True),
87 'directory': fields.char('Directory',size=64,readonly=True),
88 'create_date': fields.datetime('Date Created', readonly=True),
89 'change_date': fields.datetime('Modified Date', readonly=True),
90 'file_size': fields.integer('File Size', readonly=True),
91 'nbr':fields.integer('# of Files', readonly=True),
92 'type':fields.char('Directory Type',size=64,readonly=True),
93 'partner':fields.char('Partner',size=64,readonly=True),
97 create or replace view report_files_partner as (
98 select min(f.id) as id,count(*) as nbr,
99 min(to_char(f.create_date,'YYYY-MM-01')) as name,
100 min(f.title) as file_title,
103 inner join res_partner p
104 on (f.partner_id=p.id)
108 report_files_partner()
110 class report_document_file(osv.osv):
111 _name = "report.document.file"
112 _description = "Files details by Directory"
115 'file_size': fields.integer('File Size', readonly=True),
116 'nbr':fields.integer('# of Files', readonly=True),
117 'month': fields.char('Month', size=24,readonly=True),
122 create or replace view report_document_file as (
123 select min(f.id) as id,
125 min(EXTRACT(MONTH FROM f.create_date)||'-'||to_char(f.create_date,'Month')) as month,
126 sum(f.file_size) as file_size
128 group by EXTRACT(MONTH FROM f.create_date)
132 report_document_file()
134 class report_document_wall(osv.osv):
135 _name = "report.document.wall"
136 _description = "Users that did not inserted documents since one month"
139 'name': fields.date('Month', readonly=True),
140 'user_id':fields.many2one('res.users', 'Owner',readonly=True),
141 'user':fields.char('User',size=64,readonly=True),
142 'month': fields.char('Month', size=24,readonly=True),
143 'file_name':fields.char('Last Posted File Name',size=64,readonly=True),
144 'last':fields.datetime('Last Posted Time', readonly=True),
149 create or replace view report_document_wall as (
150 select max(f.id) as id,
151 min(title) as file_name,
152 to_char(min(f.create_date),'YYYY-MM-DD HH24:MI:SS') as last,
153 f.user_id as user_id, f.user_id as user,
154 to_char(f.create_date,'Month') as month
156 where f.create_date in (
157 select max(i.create_date)
159 inner join res_users u on (i.user_id=u.id)
160 group by i.user_id) group by f.user_id,f.create_date
161 having (CURRENT_DATE - to_date(to_char(f.create_date,'YYYY-MM-DD'),'YYYY-MM-DD')) > 30
164 report_document_wall()
165 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: