[IMP] account_asset: asset analysis improvements
bzr revid: qdp-launchpad@openerp.com-20110705142322-5e9tup635x8gf40d
This commit is contained in:
commit
d1545ea1be
|
@ -2,7 +2,7 @@
|
|||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||
# 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
|
||||
|
|
|
@ -1,25 +1,87 @@
|
|||
# -*- encoding: 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/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import tools
|
||||
from osv import fields,osv
|
||||
from osv import fields, osv
|
||||
|
||||
class asset_asset_report(osv.osv):
|
||||
_name = "asset.asset.report"
|
||||
_description = "Assets Analysis"
|
||||
_auto = False
|
||||
_columns = {
|
||||
'date': fields.date('Asset Date', readonly=True),
|
||||
'asset_id': fields.many2one('account.asset.asset',string='Asset'),
|
||||
# 'asset_category': fields.many2one('account.asset.category',string='Asset category'),
|
||||
'state': fields.related('asset_id','state',type='char', string='State', readonly=True),
|
||||
'name': fields.char('Year', size=16, required=False, readonly=True),
|
||||
'purchase_date': fields.date('Purchase Date', readonly=True),
|
||||
'depreciation_date': fields.date('Depreciation Date', readonly=True),
|
||||
'asset_id': fields.many2one('account.asset.asset', string='Asset', readonly=True),
|
||||
'asset_category_id': fields.many2one('account.asset.category',string='Asset category'),
|
||||
'partner_id': fields.many2one('res.partner', 'Partner', readonly=True),
|
||||
'state': fields.selection([('draft','Draft'),('open','Running'),('close','Close')], 'State', readonly=True),
|
||||
'depreciation_value': fields.float('Amount of Depreciation Lines', readonly=True),
|
||||
'move_check': fields.boolean('Posted', readonly=True),
|
||||
'nbr': fields.integer('# of Depreciation Lines', readonly=True),
|
||||
'gross_value': fields.float('Gross Amount', readonly=True),
|
||||
'posted_value': fields.float('Posted Amount', readonly=True),
|
||||
'unposted_value': fields.float('Unposted Amount', readonly=True),
|
||||
'company_id': fields.many2one('res.company', 'Company', readonly=True),
|
||||
}
|
||||
|
||||
def init(self, cr):
|
||||
tools.drop_view_if_exists(cr, 'asset_asset_report')
|
||||
cr.execute("""
|
||||
create or replace view asset_asset_report as (
|
||||
select id as id,
|
||||
asset_id as asset_id,
|
||||
date as date,
|
||||
state as state
|
||||
from
|
||||
account_move_line )""")
|
||||
tools.drop_view_if_exists(cr, 'asset_asset_report')
|
||||
cr.execute("""
|
||||
create or replace view asset_asset_report as (
|
||||
select
|
||||
min(dl.id) as id,
|
||||
dl.name as name,
|
||||
to_date(dl.depreciation_date, 'YYYY-MM-DD') as depreciation_date,
|
||||
a.purchase_date as purchase_date,
|
||||
(CASE WHEN (select min(d.id) from account_asset_depreciation_line as d
|
||||
left join account_asset_asset as ac ON (ac.id=d.asset_id)
|
||||
where a.id=ac.id) = min(dl.id)
|
||||
THEN a.purchase_value
|
||||
ELSE 0
|
||||
END) as gross_value,
|
||||
dl.amount as depreciation_value,
|
||||
(CASE WHEN dl.move_check
|
||||
THEN dl.amount
|
||||
ELSE 0
|
||||
END) as posted_value,
|
||||
(CASE WHEN NOT dl.move_check
|
||||
THEN dl.amount
|
||||
ELSE 0
|
||||
END) as unposted_value,
|
||||
dl.asset_id as asset_id,
|
||||
dl.move_check as move_check,
|
||||
a.category_id as asset_category_id,
|
||||
a.partner_id as partner_id,
|
||||
a.state as state,
|
||||
count(dl.*) as nbr,
|
||||
a.company_id as company_id
|
||||
from account_asset_depreciation_line dl
|
||||
left join account_asset_asset a on (dl.asset_id=a.id)
|
||||
group by
|
||||
dl.amount,dl.asset_id,to_date(dl.depreciation_date, 'YYYY-MM-DD'),dl.name,
|
||||
a.purchase_date, dl.move_check, a.state, a.category_id, a.partner_id, a.company_id,
|
||||
a.purchase_value, a.id, a.salvage_value
|
||||
)""")
|
||||
|
||||
asset_asset_report()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -1,60 +1,104 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record model="ir.ui.view" id="view_asset_asset_report_tree">
|
||||
<field name="name">asset.asset.report.tree</field>
|
||||
<field name="model">asset.asset.report</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Assets">
|
||||
</tree>
|
||||
</field>
|
||||
<field name="name">asset.asset.report.tree</field>
|
||||
<field name="model">asset.asset.report</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Assets">
|
||||
<field name="name" invisible="1"/>
|
||||
<field name="asset_id" invisible="1"/>
|
||||
<field name="asset_category_id" invisible="1"/>
|
||||
<field name="state" invisible="1"/>
|
||||
<field name="purchase_date" invisible="1"/>
|
||||
<field name="depreciation_date" invisible="1"/>
|
||||
<field name="move_check" invisible="1"/>
|
||||
<field name="company_id" invisible="1"/>
|
||||
<field name="nbr" sum="# of Depreciation Lines"/>
|
||||
<field name="gross_value"/>
|
||||
<field name="depreciation_value" sum="Amount of Depreciation Lines"/>
|
||||
<field name="posted_value"/>
|
||||
<field name="unposted_value" invisible="not context.get('unposted_value_visible', True)"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
<!-- <record model="ir.actions.act_window" id="action_account_asset_report_form">
|
||||
<field name="name">account.asset.report.graph</field>
|
||||
<field name="model">account.asset.report</field>
|
||||
<field name="type">graph</field>
|
||||
<field name="arch" type="xml">
|
||||
<graph string="Assets Analysis" type="bar">
|
||||
</graph>
|
||||
</field>
|
||||
|
||||
<record model="ir.ui.view" id="action_account_asset_report_graph">
|
||||
<field name="name">asset.asset.report.graph</field>
|
||||
<field name="model">asset.asset.report</field>
|
||||
<field name="type">graph</field>
|
||||
<field name="arch" type="xml">
|
||||
<graph string="Assets Analysis" type="bar">
|
||||
<field name="asset_id"/>
|
||||
<field name="depreciation_value"/>
|
||||
</graph>
|
||||
</field>
|
||||
</record>
|
||||
-->
|
||||
|
||||
<record id="view_asset_asset_report_search" model="ir.ui.view">
|
||||
<field name="name">asset.asset.report.search</field>
|
||||
<field name="model">asset.asset.report</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Assets Analysis">
|
||||
<group col="10" colspan="12">
|
||||
<filter string="State"
|
||||
icon="terp-stock_effects-object-colorize"
|
||||
domain="[('state','=','draft')]"
|
||||
help="Draft Assets"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group expand="1" string="Group By...">
|
||||
<filter string="Asset" name="asset_id" context="{'group_by':'asset_id'}"/>
|
||||
<filter string="Asset Category" name="asset_category"/>
|
||||
<separator orientation="vertical"/>
|
||||
<filter string="Asset Date" name="date"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
<field name="model">asset.asset.report</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Assets Analysis">
|
||||
<group col="10" colspan="12">
|
||||
<filter string="This Year" icon="terp-go-year"
|
||||
domain="[('purchase_date','<=', time.strftime('%%Y-%%m-%%d')),('purchase_date','>=',time.strftime('%%Y-01-01'))]"
|
||||
help="Assets purchased in current year"/>
|
||||
<filter string="This Month" icon="terp-go-month" name="this_month"
|
||||
domain="[('purchase_date','<=',(datetime.date.today()+relativedelta(day=31)).strftime('%%Y-%%m-%%d')),('purchase_date','>=',(datetime.date.today()-relativedelta(day=1)).strftime('%%Y-%%m-%%d'))]"
|
||||
help="Assets purchased in current month"/>
|
||||
<filter icon="terp-go-month" string="Previous Month" separator="1"
|
||||
domain="[('purchase_date','<=', (datetime.date.today() - relativedelta(day=31, months=1)).strftime('%%Y-%%m-%%d')),('purchase_date','>=',(datetime.date.today() - relativedelta(day=1,months=1)).strftime('%%Y-%%m-%%d'))]"
|
||||
help="Assets purchased in last month"/>
|
||||
<separator orientation="vertical"/>
|
||||
<filter string="Draft" icon="terp-document-new" domain="[('state','=','draft')]" help="Assets in draft state"/>
|
||||
<filter string="Running" icon="terp-check" domain="[('state','=','open')]" help="Assets in running state"/>
|
||||
<separator orientation="vertical"/>
|
||||
<filter string="Posted" name="posted" icon="terp-camera_test" domain="[('move_check','=',True)]" help="Posted depreciation lines"
|
||||
context="{'unposted_value_visible': 0}"/>
|
||||
<separator orientation="vertical"/>
|
||||
<field name="asset_id"/>
|
||||
<field name="asset_category_id"/>
|
||||
<field name="depreciation_date"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group expand="0" string="Extended Filters..." groups="base.group_extended">
|
||||
<field name="partner_id"/>
|
||||
<field name="purchase_date"/>
|
||||
<field name="company_id" groups="base.group_multi_company" widget="selection"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group expand="1" string="Group By...">
|
||||
<filter string="Asset" name="asset" context="{'group_by':'asset_id'}"/>
|
||||
<filter string="Asset Category" name="asset_category" icon="terp-stock_symbol-selection" context="{'group_by':'asset_category_id'}"/>
|
||||
<separator orientation="vertical" groups="base.group_multi_company"/>
|
||||
<filter string="Company" icon="terp-go-home" context="{'group_by':'company_id'}" groups="base.group_multi_company"/>
|
||||
<separator orientation="vertical" />
|
||||
<filter string="Purchase Date" icon="terp-go-month"
|
||||
domain="[]" context="{'group_by':'purchase_date'}" help="Date of asset purchase"/>
|
||||
<separator orientation="vertical" />
|
||||
<filter string="Depreciation Date" icon="terp-go-today"
|
||||
domain="[]" context="{'group_by':'depreciation_date'}" help="Date of depreciation"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record model="ir.actions.act_window" id="action_asset_asset_report">
|
||||
<field name="name">Assets Analysis</field>
|
||||
<field name="res_model">asset.asset.report</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree</field>
|
||||
<field name="search_view_id" ref="view_asset_asset_report_search"/>
|
||||
<field name="help">From this report, you can have an overview on all depreciation. The tool search can also be used to personalise your Assets reports and so, match this analysis to your needs;</field>
|
||||
<field name="name">Assets Analysis</field>
|
||||
<field name="res_model">asset.asset.report</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,graph</field>
|
||||
<field name="search_view_id" ref="view_asset_asset_report_search"/>
|
||||
<field name="context">{'search_default_asset_category':1, 'search_default_posted':1, 'search_default_purchase_date': time.strftime('%Y-01-01'), 'group_by':[], 'group_by_no_leaf':1}</field>
|
||||
<field name="help">From this report, you can have an overview on all depreciation. The tool search can also be used to personalise your Assets reports and so, match this analysis to your needs;</field>
|
||||
</record>
|
||||
|
||||
<menuitem action="action_asset_asset_report"
|
||||
id="menu_action_asset_asset_report"
|
||||
parent="account.menu_finance_statistic_report_statement"
|
||||
/>
|
||||
id="menu_action_asset_asset_report"
|
||||
parent="account.menu_finance_statistic_report_statement"/>
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
Loading…
Reference in New Issue