*removed everything related to analytic budget
bzr revid: qdp-79bd22e2fed50e25bbd97a4f8433b14745fad6c0
This commit is contained in:
parent
a198182c63
commit
3724cb49a2
|
@ -33,7 +33,6 @@
|
|||
"data/account_minimal.xml",
|
||||
"data/account_data2.xml",
|
||||
"account_invoice_workflow.xml",
|
||||
"project/project_wizard.xml",
|
||||
"project/project_view.xml",
|
||||
"project/project_report.xml",
|
||||
"product_data.xml",
|
||||
|
|
|
@ -50,7 +50,7 @@ class account_analytic_account(osv.osv):
|
|||
return r
|
||||
|
||||
def _debit_calc(self, cr, uid, ids, name, arg, context={}):
|
||||
|
||||
|
||||
acc_set = ",".join(map(str, ids))
|
||||
cr.execute("SELECT a.id, COALESCE(SUM(l.amount),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id) WHERE l.amount>0 and a.id IN (%s) GROUP BY a.id" % acc_set)
|
||||
r= dict(cr.fetchall())
|
||||
|
@ -67,7 +67,7 @@ class account_analytic_account(osv.osv):
|
|||
res = {}
|
||||
for account_id, sum in cr.fetchall():
|
||||
res[account_id] = sum
|
||||
|
||||
|
||||
cr.execute("SELECT a.id, r.currency_id FROM account_analytic_account a INNER JOIN res_company r ON (a.company_id = r.id) where a.id in (%s)" % acc_set)
|
||||
|
||||
currency= dict(cr.fetchall())
|
||||
|
@ -85,7 +85,7 @@ class account_analytic_account(osv.osv):
|
|||
cur_obj = res_currency.browse(cr,uid,currency.values(),context)
|
||||
cur_obj = dict([(o.id, o) for o in cur_obj])
|
||||
for id in ids:
|
||||
res[id] = res_currency.round(cr,uid,cur_obj[currency[id]],res.get(id,0.0))
|
||||
res[id] = res_currency.round(cr,uid,cur_obj[currency[id]],res.get(id,0.0))
|
||||
|
||||
return dict([(i, res[i]) for i in ids ])
|
||||
|
||||
|
@ -241,43 +241,43 @@ account_analytic_journal()
|
|||
# Budgets
|
||||
# ---------------------------------------------------------
|
||||
|
||||
class account_analytic_budget_post(osv.osv):
|
||||
_name = 'account.analytic.budget.post'
|
||||
_description = 'Budget item'
|
||||
_columns = {
|
||||
'code': fields.char('Code', size=64, required=True),
|
||||
'name': fields.char('Name', size=256, required=True),
|
||||
'sens': fields.selection( [('charge','Charge'), ('produit','Product')], 'Direction', required=True),
|
||||
'dotation_ids': fields.one2many('account.analytic.budget.post.dotation', 'post_id', 'Expenses'),
|
||||
'account_ids': fields.many2many('account.analytic.account', 'account_analytic_budget_rel', 'budget_id', 'account_id', 'Accounts'),
|
||||
}
|
||||
_defaults = {
|
||||
'sens': lambda *a: 'produit',
|
||||
}
|
||||
|
||||
def spread(self, cr, uid, ids, fiscalyear_id=False, quantity=0.0, amount=0.0):
|
||||
|
||||
dobj = self.pool.get('account.analytic.budget.post.dotation')
|
||||
for o in self.browse(cr, uid, ids):
|
||||
# delete dotations for this post
|
||||
dobj.unlink(cr, uid, dobj.search(cr, uid, [('post_id','=',o.id)]))
|
||||
|
||||
# create one dotation per period in the fiscal year, and spread the total amount/quantity over those dotations
|
||||
fy = self.pool.get('account.fiscalyear').browse(cr, uid, [fiscalyear_id])[0]
|
||||
num = len(fy.period_ids)
|
||||
for p in fy.period_ids:
|
||||
dobj.create(cr, uid, {'post_id': o.id, 'period_id': p.id, 'quantity': quantity/num, 'amount': amount/num})
|
||||
return True
|
||||
account_analytic_budget_post()
|
||||
|
||||
class account_analytic_budget_post_dotation(osv.osv):
|
||||
_name = 'account.analytic.budget.post.dotation'
|
||||
_description = "Budget item endowment"
|
||||
_columns = {
|
||||
'name': fields.char('Name', size=64),
|
||||
'post_id': fields.many2one('account.analytic.budget.post', 'Item', select=True),
|
||||
'period_id': fields.many2one('account.period', 'Period'),
|
||||
'quantity': fields.float('Quantity', digits=(16,2)),
|
||||
'amount': fields.float('Amount', digits=(16,2)),
|
||||
}
|
||||
account_analytic_budget_post_dotation()
|
||||
#class account_analytic_budget_post(osv.osv):
|
||||
# _name = 'account.analytic.budget.post'
|
||||
# _description = 'Budget item'
|
||||
# _columns = {
|
||||
# 'code': fields.char('Code', size=64, required=True),
|
||||
# 'name': fields.char('Name', size=256, required=True),
|
||||
# 'sens': fields.selection( [('charge','Charge'), ('produit','Product')], 'Direction', required=True),
|
||||
# 'dotation_ids': fields.one2many('account.analytic.budget.post.dotation', 'post_id', 'Expenses'),
|
||||
# 'account_ids': fields.many2many('account.analytic.account', 'account_analytic_budget_rel', 'budget_id', 'account_id', 'Accounts'),
|
||||
# }
|
||||
# _defaults = {
|
||||
# 'sens': lambda *a: 'produit',
|
||||
# }
|
||||
#
|
||||
# def spread(self, cr, uid, ids, fiscalyear_id=False, quantity=0.0, amount=0.0):
|
||||
#
|
||||
# dobj = self.pool.get('account.analytic.budget.post.dotation')
|
||||
# for o in self.browse(cr, uid, ids):
|
||||
# # delete dotations for this post
|
||||
# dobj.unlink(cr, uid, dobj.search(cr, uid, [('post_id','=',o.id)]))
|
||||
#
|
||||
# # create one dotation per period in the fiscal year, and spread the total amount/quantity over those dotations
|
||||
# fy = self.pool.get('account.fiscalyear').browse(cr, uid, [fiscalyear_id])[0]
|
||||
# num = len(fy.period_ids)
|
||||
# for p in fy.period_ids:
|
||||
# dobj.create(cr, uid, {'post_id': o.id, 'period_id': p.id, 'quantity': quantity/num, 'amount': amount/num})
|
||||
# return True
|
||||
#account_analytic_budget_post()
|
||||
#
|
||||
#class account_analytic_budget_post_dotation(osv.osv):
|
||||
# _name = 'account.analytic.budget.post.dotation'
|
||||
# _description = "Budget item endowment"
|
||||
# _columns = {
|
||||
# 'name': fields.char('Name', size=64),
|
||||
# 'post_id': fields.many2one('account.analytic.budget.post', 'Item', select=True),
|
||||
# 'period_id': fields.many2one('account.period', 'Period'),
|
||||
# 'quantity': fields.float('Quantity', digits=(16,2)),
|
||||
# 'amount': fields.float('Amount', digits=(16,2)),
|
||||
# }
|
||||
#account_analytic_budget_post_dotation()
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
rml="account/project/report/analytic_journal.rml"
|
||||
auto="False"
|
||||
menu="False"/>
|
||||
|
||||
|
||||
<wizard
|
||||
id="account_analytic_account_journal_report"
|
||||
string="Analytic Journal"
|
||||
|
@ -103,14 +103,14 @@
|
|||
keyword="client_print_multi"/>
|
||||
|
||||
<!--Budget -->
|
||||
<report
|
||||
<!--<report
|
||||
id="account_analytic_budget_print"
|
||||
string="Print Budget"
|
||||
model="account.analytic.budget.post"
|
||||
name="account.analytic.budget.print"
|
||||
rml="account/project/report/account_analytic_budget_report.rml"
|
||||
auto="False"
|
||||
menu="False"/>
|
||||
menu="False"/>-->
|
||||
|
||||
</data>
|
||||
</terp>
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
<field name="perm_create" eval="True"/>
|
||||
<field name="perm_unlink" eval="True"/>
|
||||
</record>-->
|
||||
|
||||
|
||||
<record model="ir.model.access" id="access_analytic_journal">
|
||||
<field name="name">Analytic Journal</field>
|
||||
<field name="model_id" model="ir.model"
|
||||
|
@ -65,8 +65,8 @@
|
|||
<field name="perm_create" eval="True"/>
|
||||
<field name="perm_unlink" eval="True"/>
|
||||
</record>-->
|
||||
|
||||
<record model="ir.model.access" id="access_analytic_budget_post">
|
||||
|
||||
<!--<record model="ir.model.access" id="access_analytic_budget_post">
|
||||
<field name="name">Budget Item</field>
|
||||
<field name="model_id" model="ir.model"
|
||||
search="[('model', '=', 'account.analytic.budget.post')]"/>
|
||||
|
@ -85,7 +85,7 @@
|
|||
<field name="perm_write" eval="True"/>
|
||||
<field name="perm_create" eval="True"/>
|
||||
<field name="perm_unlink" eval="True"/>
|
||||
</record>
|
||||
</record>-->
|
||||
|
||||
<!--<record model="ir.model.access" id="access_analytic_budget_post_account_admin">
|
||||
<field name="name">Budget Item</field>
|
||||
|
@ -97,8 +97,8 @@
|
|||
<field name="perm_create" eval="True"/>
|
||||
<field name="perm_unlink" eval="True"/>
|
||||
</record>-->
|
||||
|
||||
<record model="ir.model.access" id="access_analytic_budget_post_dotation">
|
||||
|
||||
<!--<record model="ir.model.access" id="access_analytic_budget_post_dotation">
|
||||
<field name="name">Budget Item Endowment</field>
|
||||
<field name="model_id" model="ir.model"
|
||||
search="[('model', '=', 'account.analytic.budget.post.dotation')]"/>
|
||||
|
@ -118,7 +118,7 @@
|
|||
<field name="perm_create" eval="True"/>
|
||||
<field name="perm_unlink" eval="True"/>
|
||||
</record>
|
||||
|
||||
-->
|
||||
<!--<record model="ir.model.access" id="access_analytic_budget_post_dotation_account_admin">
|
||||
<field name="name">Budget Item Endowment</field>
|
||||
<field name="model_id" model="ir.model"
|
||||
|
|
|
@ -212,7 +212,7 @@
|
|||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
<menuitem name="Financial Management/Configuration/Journal/Analytic Journal Definition" id="account_def_analytic_journal"
|
||||
<menuitem name="Financial Management/Configuration/Journal/Analytic Journal Definition" id="account_def_analytic_journal"
|
||||
action="action_account_analytic_journal_form"/>
|
||||
|
||||
#
|
||||
|
@ -243,7 +243,7 @@
|
|||
</record>
|
||||
<menuitem name="Financial Management/Reporting/Analytic/Print Analytic Journals"
|
||||
id="account_analytic_journal_print"
|
||||
action="action_account_analytic_journal_tree"/>
|
||||
action="action_account_analytic_journal_tree"/>
|
||||
|
||||
|
||||
<record model="ir.actions.act_window" id="action_account_analytic_journal_tree2">
|
||||
|
@ -257,7 +257,7 @@
|
|||
|
||||
#
|
||||
# Statistics
|
||||
#
|
||||
#
|
||||
|
||||
<record model="ir.ui.view" id="report_hr_timesheet_invoice_journal_form">
|
||||
<field name="name">report.hr.timesheet.invoice.journal.form</field>
|
||||
|
@ -311,7 +311,7 @@
|
|||
</record>
|
||||
<menuitem name="Financial Management/Reporting/Analytic/All Months/Account Cost and Revenue by Journal"
|
||||
id="report_account_analytic_journal_print"
|
||||
action="report_account_analytic_journal_tree"/>
|
||||
action="report_account_analytic_journal_tree"/>
|
||||
|
||||
<record model="ir.actions.act_window" id="report_account_analytic_journal_tree_month">
|
||||
<field name="name">Account cost and revenue by journal (This Month)</field>
|
||||
|
@ -322,12 +322,12 @@
|
|||
</record>
|
||||
<menuitem name="Financial Management/Reporting/Analytic/This Month/Account Cost and Revenue by Journal"
|
||||
id="report_account_analytic_journal_print_month"
|
||||
action="report_account_analytic_journal_tree_month"/>
|
||||
action="report_account_analytic_journal_tree_month"/>
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Budgets
|
||||
# ---------------------------------------------------------
|
||||
<record model="ir.ui.view" id="view_account_analytic_budget_post_form">
|
||||
<!--<record model="ir.ui.view" id="view_account_analytic_budget_post_form">
|
||||
<field name="name">account.analytic.budget.post.form</field>
|
||||
<field name="model">account.analytic.budget.post</field>
|
||||
<field name="type">form</field>
|
||||
|
@ -348,7 +348,7 @@
|
|||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record model="ir.ui.view" id="view_account_analytic_budget_post_tree">
|
||||
<field name="name">account.analytic.budget.post.tree</field>
|
||||
<field name="model">account.analytic.budget.post</field>
|
||||
|
@ -395,7 +395,7 @@
|
|||
<field name="view_id" ref="view_account_analytic_budget_post_tree"/>
|
||||
</record>
|
||||
|
||||
<menuitem name="Financial Management/Configuration/Budgets/Analytic Budgets" id="menu_account_analytic_budget_post_form" action="open_account_analytic_budget_post_form"/>
|
||||
<menuitem name="Financial Management/Configuration/Budgets/Analytic Budgets" id="menu_account_analytic_budget_post_form" action="open_account_analytic_budget_post_form"/>-->
|
||||
|
||||
<act_window name="All Analytic Entries"
|
||||
domain="[('account_id', '=', active_id)]"
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
<terp>
|
||||
<data>
|
||||
<!-- Budget -->
|
||||
<wizard
|
||||
string="Spread amount"
|
||||
model="account.analytic.budget.post"
|
||||
name="account.analytic.budget.spread"
|
||||
menu="False"
|
||||
id="wizard_account_analytic_budget_spread"/>
|
||||
|
||||
<wizard
|
||||
string="Budget"
|
||||
model="account.analytic.budget.post"
|
||||
name="account.analytic.budget.report"
|
||||
keyword="client_print_multi"
|
||||
id="wizard_account_analytic_budget_report"/>
|
||||
</data>
|
||||
</terp>
|
|
@ -32,4 +32,3 @@ import inverted_analytic_balance
|
|||
import cost_ledger
|
||||
import quantity_cost_ledger
|
||||
import analytic_check
|
||||
import account_analytic_budget_report
|
||||
|
|
|
@ -1,108 +0,0 @@
|
|||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
|
||||
#
|
||||
# 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 account_analytic_budget_report(report_sxw.rml_parse):
|
||||
|
||||
def __init__(self, cr, uid, name, context):
|
||||
super(account_analytic_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': total_days and (prev * period_days / total_days) or 0.0,
|
||||
'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):
|
||||
|
||||
def compute_achievements(a):
|
||||
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))
|
||||
node_achievements = float(self.cr.fetchone()[0]) * \
|
||||
(post_obj.sens == 'produit' and -1 or 1)
|
||||
childs_achievements = reduce(operator.add,
|
||||
[compute_achievements(c) for c in a.child_ids], 0)
|
||||
return node_achievements + childs_achievements
|
||||
|
||||
res = []
|
||||
for a in post_obj.account_ids:
|
||||
res.append({
|
||||
'name': a.name,
|
||||
'code': a.code,
|
||||
'achievements': compute_achievements(a),
|
||||
})
|
||||
return res
|
||||
|
||||
report_sxw.report_sxw('report.account.analytic.budget.print',
|
||||
'account.analytic.budget.post',
|
||||
'addons/account/project/report/account_analytic_budget_report.rml',
|
||||
parser=account_analytic_budget_report, header=False)
|
||||
|
File diff suppressed because one or more lines are too long
|
@ -31,5 +31,3 @@ import wizard_account_analytic_inverted_balance_report
|
|||
import wizard_account_analytic_cost_ledger_report
|
||||
import wizard_account_analytic_cost_ledger_for_journal_report
|
||||
import wizard_account_analytic_analytic_check
|
||||
import wizard_account_analytic_budget_spread
|
||||
import wizard_account_analytic_budget_report
|
||||
|
|
Loading…
Reference in New Issue