diff --git a/addons/account/__terp__.py b/addons/account/__terp__.py index 3fabb495ba1..ac20eee16b5 100644 --- a/addons/account/__terp__.py +++ b/addons/account/__terp__.py @@ -63,6 +63,7 @@ 'account_installer.xml', 'report/account_invoice_report_view.xml', 'report/account_report_view.xml', + 'report/account_analytic_report_view.xml', ], 'demo_xml': [ #'demo/price_accuracy00.yml', diff --git a/addons/account/report/__init__.py b/addons/account/report/__init__.py index 71f612e0329..09ff866d1a8 100644 --- a/addons/account/report/__init__.py +++ b/addons/account/report/__init__.py @@ -36,6 +36,7 @@ import account_balance_landscape import compare_account_balance import account_invoice_report import account_report +import account_analytic_report # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/report/account_analytic_report.py b/addons/account/report/account_analytic_report.py new file mode 100644 index 00000000000..6f08bd193f2 --- /dev/null +++ b/addons/account/report/account_analytic_report.py @@ -0,0 +1,84 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# 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 . +# +############################################################################## + +import tools +from osv import fields,osv + +class analytic_report(osv.osv): + _name = "analytic.report" + _description = "Analytic Accounts Statistics" + _auto = False + _columns = { + 'date_start': fields.date('Date Start', readonly=True), + 'date_end': fields.date('Date End',readonly=True), + 'name' : fields.char('Account', size=128, readonly=True), + 'partner_id' : fields.many2one('res.partner', 'Associated Partner',readonly=True), + 'journal_id' : fields.many2one('account.analytic.journal', 'Analytic Journal', readonly=True), + 'parent_id': fields.many2one('account.analytic.account', 'Parent Analytic Account', readonly=True), + 'user_id' : fields.many2one('res.users', 'Account Manager',readonly=True), + 'product_id' : fields.many2one('product.product', 'Product',readonly=True), + 'quantity': fields.float('Quantity',readonly=True), + 'debit' : fields.float('Debit',readonly=True), + 'credit' : fields.float('Credit',readonly=True), + 'balance' : fields.float('Balance',readonly=True), + 'year': fields.char('Year', size=4, 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), + 'state': fields.selection([('draft','Draft'), + ('open','Open'), + ('pending','Pending'), + ('cancelled', 'Cancelled'), + ('close','Close'), + ('template', 'Template')], + 'State', readonly=True), + } + _order = 'date_start desc' + def init(self, cr): + tools.drop_view_if_exists(cr, 'analytic_report') + cr.execute(""" + create or replace view analytic_report as ( + select + min(s.id) as id, + to_char(s.create_date, 'YYYY') as year, + to_char(s.create_date, 'MM') as month, + l.journal_id, + l.product_id, + s.parent_id, + s.date_start, + s.date as date_end, + s.user_id, + s.name, + s.partner_id, + s.quantity, + s.debit, + s.credit, + s.balance, + count(*) as nbr, + s.state + from account_analytic_account s + left join account_analytic_line l on (s.id=l.account_id) + GROUP BY s.create_date,s.state,l.journal_id,s.name, + s.partner_id,s.date_start,s.date,s.user_id,s.quantity, + s.debit,s.credit,s.balance,s.parent_id,l.product_id + ) + """) +analytic_report() diff --git a/addons/account/report/account_analytic_report_view.xml b/addons/account/report/account_analytic_report_view.xml new file mode 100644 index 00000000000..543b18aa6ad --- /dev/null +++ b/addons/account/report/account_analytic_report_view.xml @@ -0,0 +1,108 @@ + + + + + analytic.report.tree + analytic.report + tree + + + + + + + + + + + + + + + + + + + + + + + analytic.report.search + analytic.report + search + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Analytic Accounts + analytic.report + form + tree + + + + + + +