1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as
9 # published by the Free Software Foundation, either version 3 of the
10 # License, or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Affero General Public License for more details.
17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ##############################################################################
23 from osv import fields,osv
26 class report_document_user(osv.osv):
27 _name = "report.document.user"
28 _description = "Files details by Users"
31 'name': fields.char('Year', size=64,readonly=True),
32 'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'), ('05','May'), ('06','June'),
33 ('07','July'), ('08','August'), ('09','September'), ('10','October'), ('11','November'), ('12','December')],'Month',readonly=True),
34 'user_id':fields.integer('Owner', readonly=True),
35 'user': fields.related('user_id', 'name', type='char', size=64, readonly=True),
36 'directory': fields.char('Directory',size=64,readonly=True),
37 'datas_fname': fields.char('File Name',size=64,readonly=True),
38 'create_date': fields.datetime('Date Created', readonly=True),
39 'change_date': fields.datetime('Modified Date', readonly=True),
40 'file_size': fields.integer('File Size', readonly=True),
41 'nbr':fields.integer('# of Files', readonly=True),
42 'type':fields.char('Directory Type',size=64,readonly=True),
45 tools.drop_view_if_exists(cr, 'report_document_user')
47 CREATE OR REPLACE VIEW report_document_user as (
50 to_char(f.create_date, 'YYYY') as name,
51 to_char(f.create_date, 'MM') as month,
55 f.datas_fname as datas_fname,
56 f.create_date as create_date,
57 f.file_size as file_size,
59 f.write_date as change_date
61 left join document_directory d on (f.parent_id=d.id and d.name<>'')
62 group by to_char(f.create_date, 'YYYY'), to_char(f.create_date, 'MM'),d.name,f.parent_id,d.type,f.create_date,f.user_id,f.file_size,d.type,f.write_date,f.datas_fname
67 class report_document_file(osv.osv):
68 _name = "report.document.file"
69 _description = "Files details by Directory"
72 'file_size': fields.integer('File Size', readonly=True),
73 'nbr':fields.integer('# of Files', readonly=True),
74 'month': fields.char('Month', size=24,readonly=True),
78 tools.drop_view_if_exists(cr, 'report_document_file')
80 create or replace view report_document_file as (
81 select min(f.id) as id,
83 min(EXTRACT(MONTH FROM f.create_date)||'-'||to_char(f.create_date,'Month')) as month,
84 sum(f.file_size) as file_size
86 group by EXTRACT(MONTH FROM f.create_date)
90 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: