1 # -*- encoding: 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 ##############################################################################
22 from openerp import tools
23 from openerp.osv import fields, osv
25 class asset_asset_report(osv.osv):
26 _name = "asset.asset.report"
27 _description = "Assets Analysis"
30 'name': fields.char('Year', size=16, required=False, readonly=True),
31 'purchase_date': fields.date('Purchase Date', readonly=True),
32 'depreciation_date': fields.date('Depreciation Date', readonly=True),
33 'asset_id': fields.many2one('account.asset.asset', string='Asset', readonly=True),
34 'asset_category_id': fields.many2one('account.asset.category',string='Asset category'),
35 'partner_id': fields.many2one('res.partner', 'Partner', readonly=True),
36 'state': fields.selection([('draft','Draft'),('open','Running'),('close','Close')], 'Status', readonly=True),
37 'depreciation_value': fields.float('Amount of Depreciation Lines', readonly=True),
38 'move_check': fields.boolean('Posted', readonly=True),
39 'nbr': fields.integer('# of Depreciation Lines', readonly=True),
40 'gross_value': fields.float('Gross Amount', readonly=True),
41 'posted_value': fields.float('Posted Amount', readonly=True),
42 'unposted_value': fields.float('Unposted Amount', readonly=True),
43 'company_id': fields.many2one('res.company', 'Company', readonly=True),
47 tools.drop_view_if_exists(cr, 'asset_asset_report')
49 create or replace view asset_asset_report as (
53 dl.depreciation_date as depreciation_date,
54 a.purchase_date as purchase_date,
55 (CASE WHEN (select min(d.id) from account_asset_depreciation_line as d
56 left join account_asset_asset as ac ON (ac.id=d.asset_id)
57 where a.id=ac.id) = min(dl.id)
61 dl.amount as depreciation_value,
62 (CASE WHEN dl.move_check
66 (CASE WHEN NOT dl.move_check
69 END) as unposted_value,
70 dl.asset_id as asset_id,
71 dl.move_check as move_check,
72 a.category_id as asset_category_id,
73 a.partner_id as partner_id,
76 a.company_id as company_id
77 from account_asset_depreciation_line dl
78 left join account_asset_asset a on (dl.asset_id=a.id)
80 dl.amount,dl.asset_id,dl.depreciation_date,dl.name,
81 a.purchase_date, dl.move_check, a.state, a.category_id, a.partner_id, a.company_id,
82 a.purchase_value, a.id, a.salvage_value
87 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: