Ujjvala Collins (OpenERP) has proposed merging lp:~openerp-dev/openobject-addons/trunk-account-asset-report_asset_analysis-uco into lp:~openerp-dev/openobject-addons/trunk-account-asset.
Requested reviews: Ujjvala Collins (OpenERP) (uco-openerp): (with new specifications) Mustufa Rangwala (Open ERP) (mra-tinyerp) qdp (OpenERP) (qdp) For more details, see: https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-account-asset-report_asset_analysis-uco/+merge/63201 [IMP]: account_asset: ---------------------------------- * assets analysis report: -> 'asset analysis' depreciation lines (in reporting. Replace the existing one) * filter on "posted" (move_line_id is True) * group by asset, asset category, date -- https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-account-asset-report_asset_analysis-uco/+merge/63201 Your team OpenERP R&D Team is subscribed to branch lp:~openerp-dev/openobject-addons/trunk-account-asset.
=== modified file 'account_asset/account_asset.py' --- account_asset/account_asset.py 2011-06-23 15:15:03 +0000 +++ account_asset/account_asset.py 2011-06-29 13:26:39 +0000 @@ -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 === modified file 'account_asset/report/account_asset_report.py' --- account_asset/report/account_asset_report.py 2011-05-09 09:28:55 +0000 +++ account_asset/report/account_asset_report.py 2011-06-29 13:26:39 +0000 @@ -1,3 +1,24 @@ +# -*- 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 @@ -6,20 +27,78 @@ _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), + 'month':fields.selection([('01', 'January'), ('02', 'February'), \ + ('03', 'March'), ('04', 'April'),\ + ('05', 'May'), ('06', 'June'), \ + ('07', 'July'), ('08', 'August'),\ + ('09', 'September'), ('10', 'October'),\ + ('11', 'November'), ('12', 'December')], 'Month', readonly=True), + 'day': fields.char('Day', size=16, readonly=True), + 'purchase_date': fields.date('Asset Date', required=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', required=True, readonly=True), + 'remaining_value': fields.float('Amount of Depreciation Lines', required=True, readonly=True), + 'move_check': fields.boolean('Posted', readonly=True), + 'nbr': fields.integer('# of Depreciation Lines', readonly=True), + 'gross_value': fields.float('Gross Value', readonly=True, group_operator="avg"), + 'posted_value': fields.float('Posted Value', readonly=True), + 'unposted_value': fields.float('Unposted Value', 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, + to_char(a.purchase_date, 'YYYY') as name, + to_char(a.purchase_date, 'MM') as month, + to_char(a.purchase_date, 'YYYY-MM-DD') as day, + to_date(dl.depreciation_date, 'YYYY-MM-DD') as depreciation_date, + a.purchase_date as purchase_date, + a.purchase_value as gross_value, + dl.amount as remaining_value, + (CASE WHEN dl.move_check + THEN dl.amount + ELSE 0 + END) as posted_value, + (CASE WHEN dl.move_check + THEN (sum(a.purchase_value) - a.salvage_value - (select sum(ml.debit) from account_move_line ml + left join account_asset_asset ac on (ac.id=ml.asset_id) where ac.id=a.id)) + / (CASE WHEN + (select count(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 and d.move_check) <> 0 + THEN + (select count(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 and d.move_check) + ELSE 1 + END) + 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_asset a + left join account_asset_depreciation_line dl on (dl.asset_id=a.id) + group by + dl.amount,dl.remaining_value,dl.depreciated_value,dl.asset_id, + to_char(a.purchase_date, 'YYYY'),to_char(a.purchase_date, 'MM'), + to_char(a.purchase_date, 'YYYY-MM-DD'),to_date(dl.depreciation_date, 'YYYY-MM-DD'), + 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: === modified file 'account_asset/report/account_asset_report_view.xml' --- account_asset/report/account_asset_report_view.xml 2011-05-09 09:28:55 +0000 +++ account_asset/report/account_asset_report_view.xml 2011-06-29 13:26:39 +0000 @@ -1,60 +1,107 @@ <?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> - </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> - --> + <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="month" invisible="1"/> + <field name="day" 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="posted_value" invisible="not context.get('posted_value_visible', False)"/> + <field name="unposted_value" invisible="not context.get('unposted_value_visible', True)"/> + <field name="remaining_value" sum="# Amount of Depreciation Lines"/> + </tree> + </field> + </record> + + <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="remaining_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, 'posted_value_visible': 1}"/> + <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" string="Asset 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="Day" icon="terp-go-today" + domain="[]" context="{'group_by':'day'}" help="Day on which assets are purchased"/> + <filter string="Month" icon="terp-go-month" + domain="[]" context="{'group_by':'month'}" help="Month in which assets are purchased"/> + <filter string="Year" icon="terp-go-year" + domain="[]" context="{'group_by':'name'}" help="Year in which assets are purchased"/> + </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>
_______________________________________________ Mailing list: https://launchpad.net/~openerp-dev-gtk Post to : [email protected] Unsubscribe : https://launchpad.net/~openerp-dev-gtk More help : https://help.launchpad.net/ListHelp

