[IMP] forgot some files
bzr revid: fp@tinyerp.com-20100127065847-skrc57r55t7d3m5g
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
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()
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<menuitem name="Reporting" id="menu_reporting" parent="menu_process_changes" sequence="10"/>
|
||||
|
||||
<record model="ir.ui.view" id="view_document_change_report_search">
|
||||
<field name="name">document.change.report.search</field>
|
||||
<field name="model">document.change.report</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Coverage Analysis" col="20">
|
||||
<group col="20">
|
||||
<filter
|
||||
string="Level 1"
|
||||
domain="[('level','=',2)]"
|
||||
icon="terp-hr"/>
|
||||
<filter
|
||||
string="Level 2"
|
||||
domain="[('level','=',3)]"
|
||||
icon="terp-hr"/>
|
||||
<filter
|
||||
string="Level 3"
|
||||
domain="[('level','=',4)]"
|
||||
icon="terp-hr"/>
|
||||
<filter
|
||||
string="Level 4"
|
||||
domain="[('level','=',5)]"
|
||||
default="1"
|
||||
icon="terp-hr"/>
|
||||
|
||||
<separator orientation="vertical"/>
|
||||
<filter
|
||||
string="By Directory"
|
||||
icon="terp-hr"
|
||||
context="{'group_by':'directory_id'}"/>
|
||||
<filter
|
||||
string="By Type"
|
||||
icon="terp-hr"
|
||||
default="1"
|
||||
context="{'group_by':'change_type_id'}"/>
|
||||
<separator orientation="vertical"/>
|
||||
<field name="change_type_id" select="1" widget="selection"/>
|
||||
<field name="directory_id" select="1"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group expand="1" string="Forecasts">
|
||||
<field name="date" widget="date" select="1"
|
||||
string="Expected Date"
|
||||
domain="[]"
|
||||
context="{'date':self}"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_document_change_report">
|
||||
<field name="name">document.change.report.tree</field>
|
||||
<field name="model">document.change.report</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Coverage Analysis">
|
||||
<field name="directory_id"/>
|
||||
<field name="change_type_id"/>
|
||||
<field name="amount_required" sum="Total Required"/>
|
||||
<field name="amount_exist" sum="Total Exist"/>
|
||||
<field name="amount_percent" widget="progressbar"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="view_document_change_report_graph">
|
||||
<field name="name">document.change.report.tree</field>
|
||||
<field name="model">document.change.report</field>
|
||||
<field name="type">graph</field>
|
||||
<field name="arch" type="xml">
|
||||
<graph string="Coverage Analysis" type="bar">
|
||||
<field name="change_type_id"/>
|
||||
<field name="amount_exist"/>
|
||||
<field name="amount_required"/>
|
||||
</graph>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.actions.act_window" id="action_document_change_report">
|
||||
<field name="name">Coverage Analysis</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">document.change.report</field>
|
||||
<field name="name">Coverage Analysis</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,graph</field>
|
||||
<field name="search_view_id" ref="view_document_change_report_search"/>
|
||||
</record>
|
||||
<menuitem
|
||||
id="menu_document_change_report_config"
|
||||
action="action_document_change_report"
|
||||
parent="menu_reporting"/>
|
||||
|
||||
<act_window
|
||||
domain="[('directory_id', '=', active_id)]"
|
||||
id="act_action_document_change_report"
|
||||
name="Coverage Analysis"
|
||||
res_model="document.change.report"
|
||||
src_model="document.directory"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
Reference in New Issue
Block a user