[IMP] account: added treasury report
bzr revid: qdp-launchpad@openerp.com-20110531151231-pg36qumj491j8fsx
This commit is contained in:
parent
b5bb00cdd3
commit
107b1ebbc4
|
@ -59,6 +59,7 @@ module named account_voucher.
|
|||
'account_menuitem.xml',
|
||||
'report/account_invoice_report_view.xml',
|
||||
'report/account_entries_report_view.xml',
|
||||
'report/account_treasury_report_view.xml',
|
||||
'report/account_report_view.xml',
|
||||
'report/account_analytic_entries_report_view.xml',
|
||||
'wizard/account_move_bank_reconcile_view.xml',
|
||||
|
|
|
@ -41,6 +41,7 @@ import account_entries_report
|
|||
import account_analytic_entries_report
|
||||
import account_balance_sheet
|
||||
import account_profit_loss
|
||||
import account_treasury_report
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
# -*- 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/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import tools
|
||||
from osv import fields,osv
|
||||
import decimal_precision as dp
|
||||
|
||||
class account_treasury_report(osv.osv):
|
||||
_name = "account.treasury.report"
|
||||
_description = "Treasury Analysis"
|
||||
_auto = False
|
||||
|
||||
def _compute_balances(self, cr, uid, ids, field_names, arg=None, context=None,
|
||||
query='', query_params=()):
|
||||
all_treasury_lines = self.search(cr, uid, [], context=context)
|
||||
ref_dict = {}
|
||||
current_sum = 0
|
||||
res = dict((id, dict((fn, 0.0) for fn in field_names)) for id in all_treasury_lines)
|
||||
for record in self.browse(cr, uid, all_treasury_lines, context=context):
|
||||
res[record.id]['starting_balance'] = current_sum
|
||||
current_sum += record.balance
|
||||
res[record.id]['ending_balance'] = current_sum
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'fiscalyear_id': fields.many2one('account.fiscalyear', 'Fiscalyear', readonly=True),
|
||||
'period_id': fields.many2one('account.period', 'Period', readonly=True),
|
||||
'debit': fields.float('Debit', readonly=True),
|
||||
'credit': fields.float('Credit', readonly=True),
|
||||
'balance': fields.float('Balance', readonly=True),
|
||||
'date': fields.date('Beginning of Period Date', readonly=True),
|
||||
'starting_balance': fields.function(_compute_balances, digits_compute=dp.get_precision('Account'), method=True, string='Starting Balance', multi='balance'),
|
||||
'ending_balance': fields.function(_compute_balances, digits_compute=dp.get_precision('Account'), method=True, string='Ending Balance', multi='balance'),
|
||||
'company_id': fields.many2one('res.company', 'Company', readonly=True),
|
||||
}
|
||||
|
||||
_order = 'date asc'
|
||||
|
||||
|
||||
def init(self, cr):
|
||||
tools.drop_view_if_exists(cr, 'account_treasury_report')
|
||||
cr.execute("""
|
||||
create or replace view account_treasury_report as (
|
||||
select
|
||||
p.id as id,
|
||||
p.fiscalyear_id as fiscalyear_id,
|
||||
p.id as period_id,
|
||||
sum(l.debit) as debit,
|
||||
sum(l.credit) as credit,
|
||||
sum(l.debit-l.credit) as balance,
|
||||
p.date_start as date,
|
||||
am.company_id as company_id
|
||||
from
|
||||
account_move_line l
|
||||
left join account_account a on (l.account_id = a.id)
|
||||
left join account_move am on (am.id=l.move_id)
|
||||
left join account_period p on (am.period_id=p.id)
|
||||
where l.state != 'draft'
|
||||
and a.type = 'liquidity'
|
||||
group by p.id, p.fiscalyear_id, p.date_start, am.company_id
|
||||
)
|
||||
""")
|
||||
account_treasury_report()
|
|
@ -0,0 +1,62 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="view_account_treasury_report_tree" model="ir.ui.view">
|
||||
<field name="name">account.treasury.report.tree</field>
|
||||
<field name="model">account.treasury.report</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Treasury Analysis">
|
||||
<field name="date" invisible="1"/>
|
||||
<field name="fiscalyear_id"/>
|
||||
<field name="period_id"/>
|
||||
<field name="debit"/>
|
||||
<field name="credit"/>
|
||||
<field name="balance"/>
|
||||
<field name="starting_balance"/>
|
||||
<field name="ending_balance"/>
|
||||
<field name="company_id" invisible="1" groups="base.group_multi_company"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
<record id="view_account_treasury_report_graph" model="ir.ui.view">
|
||||
<field name="name">account.treasury.report.graph</field>
|
||||
<field name="model">account.treasury.report</field>
|
||||
<field name="type">graph</field>
|
||||
<field name="arch" type="xml">
|
||||
<graph string="Treasury Analysis" type="bar">
|
||||
<field name="period_id"/>
|
||||
<field name="balance" operator="+"/>
|
||||
</graph>
|
||||
</field>
|
||||
</record>
|
||||
<record id="view_account_treasury_report_search" model="ir.ui.view">
|
||||
<field name="name">account.treasury.report.search</field>
|
||||
<field name="model">account.treasury.report</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Treasury Analysis">
|
||||
<group colspan="10" col="12">
|
||||
<field name="fiscalyear_id"/>
|
||||
<field name="period_id"/>
|
||||
</group>
|
||||
<newline/>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
<record id="action_account_treasury_report_all" model="ir.actions.act_window">
|
||||
<field name="name">Treasury Analysis</field>
|
||||
<field name="res_model">account.treasury.report</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,graph</field>
|
||||
<field name="search_view_id" ref="view_account_treasury_report_search"/>
|
||||
<field name="view_id" ref="view_account_treasury_report_tree"/>
|
||||
<field name="context">{'group_by':[], 'group_by_no_leaf':0}</field>
|
||||
<field name="help">From this view, have an analysis of your treasury. It sums the balance of every accounting entries made on liquidity accounts per period.</field>
|
||||
</record>
|
||||
<menuitem action="action_account_treasury_report_all" id="menu_action_account_treasury_report_all"
|
||||
parent="account.menu_finance_statistic_report_statement"
|
||||
groups="group_account_manager"
|
||||
sequence="2"/>
|
||||
</data>
|
||||
</openerp>
|
Loading…
Reference in New Issue