From 14a50c5a61c7621aca4ffcfd0195f28dace010dd Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Wed, 27 Jan 2010 07:58:47 +0100 Subject: [PATCH] [IMP] forgot some files bzr revid: fp@tinyerp.com-20100127065847-skrc57r55t7d3m5g --- .../document_change/document_change_report.py | 74 +++++++++++++ .../document_change_report_view.xml | 104 ++++++++++++++++++ 2 files changed, 178 insertions(+) create mode 100644 addons/document_change/document_change_report.py create mode 100644 addons/document_change/document_change_report_view.xml diff --git a/addons/document_change/document_change_report.py b/addons/document_change/document_change_report.py new file mode 100644 index 00000000000..20c5a5993ba --- /dev/null +++ b/addons/document_change/document_change_report.py @@ -0,0 +1,74 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from osv import fields,osv + +class document_change_report(osv.osv): + _name = "document.change.report" + _description = "Process Changes Report" + _auto = False + def _amount_all(self, cr, uid, ids, field_name, arg, context): + res = {} + for id in ids: + print context + dir, type = id.split(' ') + att = self.pool.get('ir.attachment') + fids = att.search(cr, uid, [('parent_id','child_of',[int(dir)]),('change_type_id','=',int(type))], context=context) + res[id] = { + 'amount_required': 0, + 'amount_exist': 0, + 'amount_percent': 0.0 + } + for f in att.browse(cr, uid, fids, context=context): + res[id] = { + 'amount_required': res[id]['amount_required'] + 1, + 'amount_exist': res[id]['amount_exist'] + (f.state<>'draft') and 1 or 0, + } + if res[id]['amount_required']: + res[id]['amount_percent'] = float(res[id]['amount_exist']*100) / res[id]['amount_required'] + return res + + _columns = { + 'directory_id': fields.many2one('document.directory', 'Directory', readonly=True), + 'change_type_id': fields.many2one('document.change.type', 'Document Type', readonly=True), + 'level': fields.integer('Level', readonly=True), + 'amount_required': fields.function(_amount_all, method=True, + string='Required', multi='sums', type='integer'), + 'date': fields.date('Date', readonly=True), + 'amount_exist': fields.function(_amount_all, method=True, + string='Existing', multi='sums', type='integer'), + 'amount_percent': fields.function(_amount_all, method=True, + string='% Coverage', multi='sums', type='float', digits=(16,2)), + } + def init(self, cr): + cr.execute(""" + create or replace view document_change_report as ( + select + d.id || ' ' || t.id as id, + d.id as directory_id, + d.level as level, + t.id as change_type_id + from + document_directory d, + document_change_type t + )""") +document_change_report() + diff --git a/addons/document_change/document_change_report_view.xml b/addons/document_change/document_change_report_view.xml new file mode 100644 index 00000000000..5d9b979e9dd --- /dev/null +++ b/addons/document_change/document_change_report_view.xml @@ -0,0 +1,104 @@ + + + + + + + document.change.report.search + document.change.report + search + + + + + + + + + + + + + + + + + + + + + + + + + document.change.report.tree + document.change.report + tree + + + + + + + + + + + + document.change.report.tree + document.change.report + graph + + + + + + + + + + Coverage Analysis + ir.actions.act_window + document.change.report + Coverage Analysis + form + tree,graph + + + + + + + +