From 1ceb037e4a6dade26c78ba7b4789ad25f16004e3 Mon Sep 17 00:00:00 2001
From: pinky <>
Date: Mon, 18 Dec 2006 14:16:10 +0000
Subject: [PATCH] Report account module
Analytic report
bzr revid: pinky-0f1fc9241566037f99ddd0c942a56aee4dc983a1
---
.../report/account_analytic_to_invoice.py | 106 ++++++++++++++++++
addons/product/product.py | 2 +-
addons/report_account/__init__.py | 30 +++++
addons/report_account/__terp__.py | 14 +++
addons/report_account/report_receivable.py | 68 +++++++++++
.../report_account/report_receivable_view.xml | 66 +++++++++++
addons/report_analytic/report_analytic.py | 66 ++++++-----
.../report_analytic/report_analytic_view.xml | 25 ++---
8 files changed, 329 insertions(+), 48 deletions(-)
create mode 100644 addons/hr_timesheet_invoice/report/account_analytic_to_invoice.py
create mode 100644 addons/report_account/__init__.py
create mode 100644 addons/report_account/__terp__.py
create mode 100644 addons/report_account/report_receivable.py
create mode 100644 addons/report_account/report_receivable_view.xml
diff --git a/addons/hr_timesheet_invoice/report/account_analytic_to_invoice.py b/addons/hr_timesheet_invoice/report/account_analytic_to_invoice.py
new file mode 100644
index 00000000000..73a432da824
--- /dev/null
+++ b/addons/hr_timesheet_invoice/report/account_analytic_to_invoice.py
@@ -0,0 +1,106 @@
+##############################################################################
+#
+# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
+#
+# $Id: project.py 1005 2005-07-25 08:41:42Z nicoe $
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsability of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# garantees and support are strongly adviced to contract a Free Software
+# Service Company
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+##############################################################################
+
+from osv import fields,osv
+
+class account_analytic_to_invoice(osv.osv):
+ _name = "account"
+ _description = "Cases by user and section"
+ _auto = False
+ _columns = {
+ 'name': fields.date('Month', readonly=True),
+ 'user_id':fields.many2one('res.users', 'User', readonly=True, relate=True),
+ 'section_id':fields.many2one('crm.case.section', 'Section', readonly=True, relate=True),
+ 'amount_revenue': fields.float('Est.Revenue', readonly=True),
+ 'amount_costs': fields.float('Est.Cost', readonly=True),
+ 'amount_revenue_prob': fields.float('Est. Rev*Prob.', readonly=True),
+ 'nbr': fields.integer('# of Cases', readonly=True),
+ 'probability': fields.float('Avg. Probability', readonly=True),
+ 'state': fields.selection(AVAILABLE_STATES, 'State', size=16, readonly=True),
+ 'delay_close': fields.integer('Delay to close', readonly=True),
+ }
+ _order = 'name desc, user_id, section_id'
+ def init(self, cr):
+ cr.execute("""
+ create or replace view report_crm_case_user as (
+ select
+ min(c.id) as id,
+ substring(c.create_date for 7)||'-01' as name,
+ c.state,
+ c.user_id,
+ c.section_id,
+ count(*) as nbr,
+ sum(planned_revenue) as amount_revenue,
+ sum(planned_cost) as amount_costs,
+ sum(planned_revenue*probability)::decimal(16,2) as amount_revenue_prob,
+ avg(probability)::decimal(16,2) as probability,
+ to_char(avg(date_closed-c.create_date), 'DD"d" HH12:MI:SS') as delay_close
+ from
+ crm_case c
+ group by substring(c.create_date for 7), c.state, c.user_id, c.section_id
+ )""")
+report_crm_case_user()
+
+class report_crm_case_categ(osv.osv):
+ _name = "report.crm.case.categ"
+ _description = "Cases by section and category"
+ _auto = False
+ _columns = {
+ 'name': fields.date('Month', readonly=True),
+ 'categ_id':fields.many2one('crm.case.categ', 'Category', readonly=True, relate=True),
+ 'section_id':fields.many2one('crm.case.section', 'Section', readonly=True, relate=True),
+ 'amount_revenue': fields.float('Est.Revenue', readonly=True),
+ 'amount_costs': fields.float('Est.Cost', readonly=True),
+ 'amount_revenue_prob': fields.float('Est. Rev*Prob.', readonly=True),
+ 'nbr': fields.integer('# of Cases', readonly=True),
+ 'probability': fields.float('Avg. Probability', readonly=True),
+ 'state': fields.selection(AVAILABLE_STATES, 'State', size=16, readonly=True),
+ 'delay_close': fields.integer('Delay Close', readonly=True),
+ }
+ _order = 'name desc, categ_id, section_id'
+ def init(self, cr):
+ cr.execute("""
+ create or replace view report_crm_case_categ as (
+ select
+ min(c.id) as id,
+ substring(c.create_date for 7)||'-01' as name,
+ c.state,
+ c.categ_id,
+ c.section_id,
+ count(*) as nbr,
+ sum(planned_revenue) as amount_revenue,
+ sum(planned_cost) as amount_costs,
+ sum(planned_revenue*probability)::decimal(16,2) as amount_revenue_prob,
+ avg(probability)::decimal(16,2) as probability,
+ to_char(avg(date_closed-c.create_date), 'DD"d" HH12:MI:SS') as delay_close
+ from
+ crm_case c
+ group by substring(c.create_date for 7), c.state, c.categ_id, c.section_id
+ )""")
+report_crm_case_categ()
diff --git a/addons/product/product.py b/addons/product/product.py
index ff4a380c5c0..2af9f1240d7 100644
--- a/addons/product/product.py
+++ b/addons/product/product.py
@@ -215,7 +215,7 @@ class product_template(osv.osv):
'uom_id': _get_uom_id,
'uom_po_id': _get_uom_id,
#'uom_price_id' : _get_uom_id,
- 'uos_id' : _get_uom_id,
+ #'uos_id' : _get_uom_id,
'uos_coeff' : lambda *a: 1.0,
'mes_type' : lambda *a: 'fixed',
}
diff --git a/addons/report_account/__init__.py b/addons/report_account/__init__.py
new file mode 100644
index 00000000000..c7670e6ab32
--- /dev/null
+++ b/addons/report_account/__init__.py
@@ -0,0 +1,30 @@
+##############################################################################
+#
+# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
+#
+# $Id: __init__.py 1005 2005-07-25 08:41:42Z nicoe $
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsability of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# garantees and support are strongly adviced to contract a Free Software
+# Service Company
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+##############################################################################
+
+import report_account
diff --git a/addons/report_account/__terp__.py b/addons/report_account/__terp__.py
new file mode 100644
index 00000000000..c3177df9855
--- /dev/null
+++ b/addons/report_account/__terp__.py
@@ -0,0 +1,14 @@
+{
+ "name" : "Account Reporting - Reporting",
+ "version" : "1.0",
+ "author" : "Tiny",
+ "website" : "http://tinyerp.com",
+ "depends" : ["account"],
+ "category" : "Generic Modules/Accounting",
+ "description": "A module that adds new reports based on the account module.",
+ "init_xml" : [],
+ "demo_xml" : [],
+ "update_xml" : ["report_account_view.xml"],
+ "active": False,
+ "installable": True
+}
diff --git a/addons/report_account/report_receivable.py b/addons/report_account/report_receivable.py
new file mode 100644
index 00000000000..a81688ba741
--- /dev/null
+++ b/addons/report_account/report_receivable.py
@@ -0,0 +1,68 @@
+##############################################################################
+#
+# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
+#
+# $Id: project.py 1005 2005-07-25 08:41:42Z nicoe $
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsability of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# garantees and support are strongly adviced to contract a Free Software
+# Service Company
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+##############################################################################
+
+from osv import fields,osv
+
+class report_account_receivable(osv.osv):
+ _name = "report.account.receivable"
+ _description = "Receivable accounts"
+ _auto = False
+ _columns = {
+ 'name': fields.date('Month', readonly=True),
+ 'user_id':fields.many2one('res.users', 'User', readonly=True, relate=True),
+ 'section_id':fields.many2one('crm.case.section', 'Section', readonly=True, relate=True),
+ 'amount_revenue': fields.float('Est.Revenue', readonly=True),
+ 'amount_costs': fields.float('Est.Cost', readonly=True),
+ 'amount_revenue_prob': fields.float('Est. Rev*Prob.', readonly=True),
+ 'nbr': fields.integer('# of Cases', readonly=True),
+ 'probability': fields.float('Avg. Probability', readonly=True),
+ 'state': fields.selection(AVAILABLE_STATES, 'State', size=16, readonly=True),
+ 'delay_close': fields.integer('Delay to close', readonly=True),
+ }
+ _order = 'name desc, user_id, section_id'
+ def init(self, cr):
+ cr.execute("""
+ create or replace view report_crm_case_user as (
+ select
+ min(c.id) as id,
+ substring(c.create_date for 7)||'-01' as name,
+ c.state,
+ c.user_id,
+ c.section_id,
+ count(*) as nbr,
+ sum(planned_revenue) as amount_revenue,
+ sum(planned_cost) as amount_costs,
+ sum(planned_revenue*probability)::decimal(16,2) as amount_revenue_prob,
+ avg(probability)::decimal(16,2) as probability,
+ to_char(avg(date_closed-c.create_date), 'DD"d" HH12:MI:SS') as delay_close
+ from
+ crm_case c
+ group by substring(c.create_date for 7), c.state, c.user_id, c.section_id
+ )""")
+report_crm_case_user()
diff --git a/addons/report_account/report_receivable_view.xml b/addons/report_account/report_receivable_view.xml
new file mode 100644
index 00000000000..11f02fbb9f3
--- /dev/null
+++ b/addons/report_account/report_receivable_view.xml
@@ -0,0 +1,66 @@
+
+
+
+
+ #
+ # Cases by user and section
+ #
+
+
+ report.crm.case.user.tree
+ report.crm.case.user
+ tree
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ report.crm.case.user.form
+ report.crm.case.user
+ form
+
+
+
+
+
+
+ report.crm.case.user.graph
+ report.crm.case.user
+ graph
+
+
+
+
+
+
+
+
+
+
+ report.crm.case.user.tree
+ report.crm.case.user
+ form
+ tree,graph
+ [('name','=',time.strftime('%Y-%m-01'))]
+
+
+
+
+
diff --git a/addons/report_analytic/report_analytic.py b/addons/report_analytic/report_analytic.py
index c81bb7945a5..f4ff0a418fb 100644
--- a/addons/report_analytic/report_analytic.py
+++ b/addons/report_analytic/report_analytic.py
@@ -30,38 +30,36 @@
from osv import fields,osv
class report_analytic_account_close(osv.osv):
- _name = "report.analytic.account.close"
- _description = "Analytic account to close"
- _auto = False
- _columns = {
- 'name': fields.many2one('account.analytic.account', 'Analytic account', readonly=True),
- 'partner_id': fields.many2one('res.partner', 'Partner', readonly=True),
- 'quantity': fields.float('Quantity', readonly=True),
- 'quantity_max': fields.float('Max. Quantity', readonly=True),
- 'balance': fields.float('Balance', readonly=True),
- 'date_deadline': fields.date('Deadline', readonly=True),
- }
- def init(self, cr):
- cr.execute("""
- create or replace view report_crm_case_user as (
- select
- l.account_id as id,
- l.account_id as name,
- sum(l.unit_amount) as quantity,
- sum(l.amount) as balance,
- a.partner_id as partner_id,
- a.quantity_max as quantity_max,
- a.date as date_deadline
- from
- account_analytic_line l
- left join
- account_analytic_account a on (l.account_id=a.id)
- where
- a.state='open'
- group by
- l.account_id,a.quantity_max,a.date,a.partner_id
- having
- sum(l.unit_amount)>=a.quantity_max or
- a.date <= current_date
- )""")
+ _name = "report.analytic.account.close"
+ _description = "Analytic account to close"
+ _auto = False
+ _columns = {
+ 'name': fields.many2one('account.analytic.account', 'Analytic account', readonly=True),
+ 'partner_id': fields.many2one('res.partner', 'Partner', readonly=True),
+ 'quantity': fields.float('Quantity', readonly=True),
+ 'quantity_max': fields.float('Max. Quantity', readonly=True),
+ 'balance': fields.float('Balance', readonly=True),
+ 'date_deadline': fields.date('Deadline', readonly=True),
+ }
+ def init(self, cr):
+ cr.execute("""
+ create or replace view report_analytic_account_close as (
+ select
+ a.id as id,
+ a.id as name,
+ sum(l.unit_amount) as quantity,
+ sum(l.amount) as balance,
+ a.partner_id as partner_id,
+ a.quantity_max as quantity_max,
+ a.date as date_deadline
+ from
+ account_analytic_line l
+ right join
+ account_analytic_account a on (l.account_id=a.id)
+ group by
+ a.id,a.quantity_max,a.date,a.partner_id
+ having
+ (a.quantity_max>0 and (sum(l.unit_amount)>=a.quantity_max)) or
+ a.date <= current_date
+ )""")
report_analytic_account_close()
diff --git a/addons/report_analytic/report_analytic_view.xml b/addons/report_analytic/report_analytic_view.xml
index b92a04a1060..7c45d0ed756 100644
--- a/addons/report_analytic/report_analytic_view.xml
+++ b/addons/report_analytic/report_analytic_view.xml
@@ -6,12 +6,12 @@
# Analytic accounts to close
#
-
- report.analytic.account.form
- report.analytic.account
+
+ report.analytic.account.close.form
+ report.analytic.account.close
form
-
-
- report.analytic.account.tree
- report.analytic.account
+
+ report.analytic.account.close.tree
+ report.analytic.account.close
tree
-
+
@@ -40,8 +40,8 @@
- report.analytic.account.graph
- report.analytic.account
+ report.analytic.account.close.graph
+ report.analytic.account.close
graph
@@ -53,8 +53,8 @@
- report.analytic.account.tree
- report.analytic.account
+ report.analytic.account.close.tree
+ report.analytic.account.close
form
tree,graph
@@ -62,6 +62,5 @@
action="action_analytic_account_tree"
id="menu_action_analytic_account_tree"/>
-