-
- account.analytic.account.form.inherot.cci
@@ -249,6 +329,16 @@
+
+
+
diff --git a/addons/account_budget_crossover/report/__init__.py b/addons/account_budget_crossover/report/__init__.py
index 29e13bf6c0e..44546c1ad6d 100644
--- a/addons/account_budget_crossover/report/__init__.py
+++ b/addons/account_budget_crossover/report/__init__.py
@@ -1,5 +1,6 @@
# -*- encoding: utf-8 -*-
import crossovered_budget_report
import analytic_account_budget_report
+import budget_report
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account_budget_crossover/report/budget_report.py b/addons/account_budget_crossover/report/budget_report.py
new file mode 100644
index 00000000000..0356817535f
--- /dev/null
+++ b/addons/account_budget_crossover/report/budget_report.py
@@ -0,0 +1,78 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
+#
+# $Id$
+#
+# 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 time
+from report import report_sxw
+import datetime
+import operator
+
+class budget_report(report_sxw.rml_parse):
+ def __init__(self, cr, uid, name, context):
+ super(budget_report, self).__init__(cr, uid, name, context)
+ self.localcontext.update( {
+ 'lines': self.lines,
+ 'budget_total': self.budget_total,
+ 'post_total': self.post_total,
+ 'time': time,
+ })
+
+ def post_total(self, post_obj, date1, date2):
+ def str2date(date_str):
+ return datetime.date.fromtimestamp(time.mktime(time.strptime(date_str, '%Y-%m-%d')))
+ def interval(d1str, d2str):
+ return (str2date(d2str) - str2date(d1str) + datetime.timedelta(days=1)).days
+ prev = reduce(lambda x,d: x + d.amount, post_obj.dotation_ids, 0.0)
+ period_days = interval(date1, date2)
+ for d in post_obj.dotation_ids:
+ i = interval(d.period_id.date_start, d.period_id.date_stop)
+ total_days = reduce(lambda x,d: x+interval(d.period_id.date_start, d.period_id.date_stop), post_obj.dotation_ids, 0)
+ achievements = reduce(lambda x,l: x+l['achievements'], self.lines(post_obj, date1, date2), 0.0)
+ return [{'prev': prev, 'prev_period': prev * period_days / total_days, 'achievements': achievements}]
+
+ def budget_total(self, post_objs, date1, date2):
+ res = {'prev': 0.0, 'prev_period': 0.0, 'achievements': 0.0}
+ for post_obj in post_objs:
+ r = self.post_total(post_obj, date1, date2)[0]
+ for k in r:
+ res[k] += r[k]
+ return [res]
+
+ def lines(self, post_obj, date1, date2):
+ res = []
+ for a in post_obj.account_ids:
+ self.cr.execute("SELECT COALESCE(SUM(debit-credit), 0) FROM account_move_line WHERE account_id=%d AND date>=%s AND date<=%s and state<>'draft'", (a.id, date1, date2))
+ achievements = float(self.cr.fetchone()[0]) * (post_obj.sens=='produit' and -1 or 1)
+ res.append({'name': a.name, 'code': a.code, 'achievements': achievements})
+ return res
+report_sxw.report_sxw('report.account.budget', 'account.budget.post', 'addons/account/report/budget_report.rml',parser=budget_report)
+
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/account_budget_crossover/report/budget_report.rml b/addons/account_budget_crossover/report/budget_report.rml
new file mode 100644
index 00000000000..520fed1df2f
--- /dev/null
+++ b/addons/account_budget_crossover/report/budget_report.rml
@@ -0,0 +1,248 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Budget Analysis
+
+
+ From [[ data['form']['date1'] ]]
+ to [[ data['form']['date2'] ]]
+
+
+
+
+
+
+
+
diff --git a/addons/account_budget_crossover/security/ir.model.access.csv b/addons/account_budget_crossover/security/ir.model.access.csv
index a87fc1c28ce..682a2ea3783 100644
--- a/addons/account_budget_crossover/security/ir.model.access.csv
+++ b/addons/account_budget_crossover/security/ir.model.access.csv
@@ -1,3 +1,5 @@
-id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
-access_crossovered_budget,crossovered.budget,model_crossovered_budget,account.group_account_manager,1,1,1,1
-access_crossovered_budget_lines,crossovered.budget.lines,model_crossovered_budget_lines,account.group_account_manager,1,1,1,1
+"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
+"access_crossovered_budget","crossovered.budget","model_crossovered_budget","account.group_account_manager",1,1,1,1
+"access_crossovered_budget_lines","crossovered.budget.lines","model_crossovered_budget_lines","account.group_account_manager",1,1,1,1
+"access_account_budget_post","account.budget.post","model_account_budget_post","account.group_account_manager",1,1,1,1
+"access_account_budget_post_dotation","account.budget.post.dotation","model_account_budget_post_dotation","account.group_account_manager",1,1,1,1
diff --git a/addons/account_budget_crossover/wizard/__init__.py b/addons/account_budget_crossover/wizard/__init__.py
index 63a94c33df4..acde7263aed 100644
--- a/addons/account_budget_crossover/wizard/__init__.py
+++ b/addons/account_budget_crossover/wizard/__init__.py
@@ -2,5 +2,8 @@
import wizard_crossovered_budget_report
import wizard_analytic_account_budget
import wizard_crossovered_budget_summary_report
+
+import wizard_budget_spread
+import wizard_budget_report
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account_budget_crossover/wizard/wizard_budget_report.py b/addons/account_budget_crossover/wizard/wizard_budget_report.py
new file mode 100644
index 00000000000..93ee44850c0
--- /dev/null
+++ b/addons/account_budget_crossover/wizard/wizard_budget_report.py
@@ -0,0 +1,61 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
+#
+# $Id$
+#
+# 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 time
+import wizard
+
+dates_form = '''
+
+
+
+
'''
+
+dates_fields = {
+ 'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
+ 'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
+}
+
+class wizard_report(wizard.interface):
+ states = {
+ 'init': {
+ 'actions': [],
+ 'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('report','Print')]}
+ },
+ 'report': {
+ 'actions': [],
+ 'result': {'type':'print', 'report':'account.budget', 'state':'end'}
+ }
+ }
+wizard_report('account.budget.report')
+
+
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/account_budget_crossover/wizard/wizard_budget_spread.py b/addons/account_budget_crossover/wizard/wizard_budget_spread.py
new file mode 100644
index 00000000000..e93c13a2ed2
--- /dev/null
+++ b/addons/account_budget_crossover/wizard/wizard_budget_spread.py
@@ -0,0 +1,66 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
+#
+# $Id$
+#
+# 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 wizard
+import netsvc
+
+_spread_form = '''
+