[REF] Account budget: Improve code
bzr revid: mra@mra-laptop-20100928125800-ulr19iodfk4ktqek
This commit is contained in:
parent
67df45204a
commit
1fb19d0091
|
@ -18,6 +18,7 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import datetime
|
||||
|
||||
from osv import osv, fields
|
||||
|
@ -42,7 +43,7 @@ class account_budget_post(osv.osv):
|
|||
'company_id': fields.many2one('res.company', 'Company', required=True),
|
||||
}
|
||||
_defaults = {
|
||||
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.budget.post', context=c)
|
||||
'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.budget.post', context=c)
|
||||
}
|
||||
_order = "name"
|
||||
|
||||
|
@ -62,8 +63,8 @@ class account_budget_post(osv.osv):
|
|||
account_budget_post()
|
||||
|
||||
class account_budget_post_dotation(osv.osv):
|
||||
def _tot_planned(self, cr, uid, ids,name,args,context):
|
||||
res={}
|
||||
def _tot_planned(self, cr, uid, ids, name, args, context):
|
||||
res = {}
|
||||
for line in self.browse(cr, uid, ids):
|
||||
if line.period_id:
|
||||
obj_period=self.pool.get('account.period').browse(cr, uid, line.period_id.id)
|
||||
|
@ -75,7 +76,6 @@ class account_budget_post_dotation(osv.osv):
|
|||
OR (date_to >=%s and date_to <= %s) OR (date_from < %s and date_to > %s)"
|
||||
cr.execute(query,(budget_id,obj_period.date_start,obj_period.date_stop,obj_period.date_start,obj_period.date_stop,obj_period.date_start,obj_period.date_stop,))
|
||||
res1=cr.fetchall()
|
||||
|
||||
tot_planned=0.00
|
||||
for record in res1:
|
||||
obj_lines = self.pool.get('crossovered.budget.lines').browse(cr, uid, record[0])
|
||||
|
@ -84,9 +84,9 @@ class account_budget_post_dotation(osv.osv):
|
|||
count_days = strToDate(obj_lines.date_to) - strToDate(obj_lines.date_from)
|
||||
total_days_of_rec = count_days.days +1
|
||||
tot_planned += obj_lines.planned_amount/total_days_of_rec* days_in_period
|
||||
res[line.id]=tot_planned
|
||||
res[line.id] = tot_planned
|
||||
else:
|
||||
res[line.id]=0.00
|
||||
res[line.id] = 0.00
|
||||
return res
|
||||
|
||||
_name = 'account.budget.post.dotation'
|
||||
|
@ -143,7 +143,6 @@ class crossovered_budget(osv.osv):
|
|||
return True
|
||||
|
||||
def budget_cancel(self, cr, uid, ids, *args):
|
||||
|
||||
self.write(cr, uid, ids, {
|
||||
'state':'cancel'
|
||||
})
|
||||
|
@ -165,7 +164,6 @@ class crossovered_budget_lines(osv.osv):
|
|||
acc_ids = [x.id for x in line.general_budget_id.account_ids]
|
||||
if not acc_ids:
|
||||
raise osv.except_osv(_('Error!'),_("The General Budget '%s' has no Accounts!") % str(line.general_budget_id.name))
|
||||
|
||||
date_to = line.date_to
|
||||
date_from = line.date_from
|
||||
if context.has_key('wizard_date_from'):
|
||||
|
@ -185,7 +183,6 @@ class crossovered_budget_lines(osv.osv):
|
|||
res={}
|
||||
for line in self.browse(cr, uid, ids):
|
||||
res[line.id]=self._prac_amt(cr, uid, [line.id], context=context)[line.id]
|
||||
|
||||
return res
|
||||
|
||||
def _theo_amt(self, cr, uid, ids,context={}):
|
||||
|
@ -233,7 +230,8 @@ class crossovered_budget_lines(osv.osv):
|
|||
else:
|
||||
res[line.id]=0.00
|
||||
return res
|
||||
_name="crossovered.budget.lines"
|
||||
|
||||
_name = "crossovered.budget.lines"
|
||||
_description = "Budget Line"
|
||||
_columns = {
|
||||
'crossovered_budget_id': fields.many2one('crossovered.budget', 'Budget', ondelete='cascade', select=True, required=True),
|
||||
|
@ -252,7 +250,6 @@ class crossovered_budget_lines(osv.osv):
|
|||
crossovered_budget_lines()
|
||||
|
||||
class account_analytic_account(osv.osv):
|
||||
_name = 'account.analytic.account'
|
||||
_inherit = 'account.analytic.account'
|
||||
|
||||
_columns = {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
|
@ -15,12 +15,13 @@
|
|||
# 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/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import crossovered_budget_report
|
||||
import analytic_account_budget_report
|
||||
import budget_report
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
|
|
@ -20,9 +20,10 @@
|
|||
##############################################################################
|
||||
|
||||
import time
|
||||
import datetime
|
||||
|
||||
import pooler
|
||||
from report import report_sxw
|
||||
import datetime
|
||||
|
||||
class analytic_account_budget_report(report_sxw.rml_parse):
|
||||
def __init__(self, cr, uid, name, context):
|
||||
|
@ -34,7 +35,6 @@ class analytic_account_budget_report(report_sxw.rml_parse):
|
|||
})
|
||||
self.context=context
|
||||
|
||||
|
||||
def funct(self,object,form,ids={}, done=None, level=1):
|
||||
|
||||
if not ids:
|
||||
|
@ -181,5 +181,5 @@ class analytic_account_budget_report(report_sxw.rml_parse):
|
|||
return result
|
||||
|
||||
report_sxw.report_sxw('report.account.analytic.account.budget', 'account.analytic.account', 'addons/account_budget/report/analytic_account_budget_report.rml',parser=analytic_account_budget_report,header='internal')
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -20,8 +20,9 @@
|
|||
##############################################################################
|
||||
|
||||
import time
|
||||
from report import report_sxw
|
||||
import datetime
|
||||
|
||||
from report import report_sxw
|
||||
import operator
|
||||
|
||||
class budget_report(report_sxw.rml_parse):
|
||||
|
@ -64,8 +65,8 @@ class budget_report(report_sxw.rml_parse):
|
|||
achievements = float(self.cr.fetchone()[0])
|
||||
res.append({'name': a.name, 'code': a.code, 'achievements': achievements})
|
||||
return res
|
||||
|
||||
report_sxw.report_sxw('report.account.budget', 'account.budget.post', 'addons/account_budget/report/budget_report.rml',parser=budget_report, header="internal")
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -53,5 +53,4 @@ class account_budget_analytic(osv.osv_memory):
|
|||
|
||||
account_budget_analytic()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -18,6 +18,7 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import time
|
||||
|
||||
from osv import fields, osv
|
||||
|
@ -54,5 +55,4 @@ class account_budget_crossvered_report(osv.osv_memory):
|
|||
|
||||
account_budget_crossvered_report()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -18,7 +18,7 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
import netsvc
|
||||
|
||||
from osv import fields, osv
|
||||
import decimal_precision as dp
|
||||
|
||||
|
|
Loading…
Reference in New Issue