[IMP] Account: General ledger and account balance used inhertiance with common report

bzr revid: mra@mra-laptop-20100713043221-ioe9covnp3r1o55n
This commit is contained in:
Mustufa Rangwala 2010-07-13 10:02:21 +05:30
parent 891bbd761c
commit a25ace244f
3 changed files with 12 additions and 42 deletions

View File

@ -19,22 +19,14 @@
#
##############################################################################
import xml
import copy
from operator import itemgetter
import datetime
import xml.dom.minidom
import os, time
import re
import sys
from report import report_sxw
import osv
import tools
import pooler
from tools.translate import _
from account_journal_common_default import account_journal_common_default
class account_balance(report_sxw.rml_parse):
class account_balance(report_sxw.rml_parse, account_journal_common_default):
_name = 'report.account.account.balance'
def set_context(self, objects, data, ids, report_type = None):
@ -56,7 +48,7 @@ class account_balance(report_sxw.rml_parse):
'lines': self.lines,
'sum_debit': self._sum_debit,
'sum_credit': self._sum_credit,
'get_fiscalyear':self.get_fiscalyear,
'get_fiscalyear':self._get_fiscalyear,
'get_periods':self.get_periods,
})
self.context = context
@ -66,16 +58,6 @@ class account_balance(report_sxw.rml_parse):
self.rml_header = ""
return True
def get_fiscalyear(self, form):
res=[]
if form.has_key('fiscalyear_id'):
fisc_id = form['fiscalyear_id']
if not (fisc_id):
return ''
self.cr.execute("select name from account_fiscalyear where id = %s" , (int(fisc_id),))
res=self.cr.fetchone()
return res and res[0] or ''
def get_periods(self, form):
result=''
if form.has_key('periods') and form['periods']:

View File

@ -110,4 +110,9 @@ class account_journal_common_default(object):
return self.cr.fetchone()[0] or 0.0
def _get_fiscalyear(self,form):
if data.get('form', False) and data['form'].get('fiscalyear_id', False):
return pooler.get_pool(self.cr.dbname).get('account.fiscalyear').browse(self.cr, self.uid, data['form']['fiscalyear_id']).name
return ''
#vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -29,10 +29,11 @@
import time
from report import report_sxw
from account_journal_common_default import account_journal_common_default
import rml_parse
import pooler
class general_ledger(rml_parse.rml_parse):
class general_ledger(rml_parse.rml_parse, account_journal_common_default):
_name = 'report.account.general.ledger'
def set_context(self, objects, data, ids, report_type=None):
@ -65,8 +66,8 @@ class general_ledger(rml_parse.rml_parse):
'sum_solde': self._sum_solde,
'get_children_accounts': self.get_children_accounts,
'sum_currency_amount_account': self._sum_currency_amount_account,
'get_fiscalyear': self.get_fiscalyear,
'get_account': self.get_account,
'get_fiscalyear': self._get_fiscalyear,
'get_account': self._get_account,
'get_start_period': self.get_start_period,
'get_end_period': self.get_end_period,
})
@ -325,24 +326,6 @@ class general_ledger(rml_parse.rml_parse):
currency_total = self.tot_currency = 0.0
return currency_total
def get_fiscalyear(self,form):
return pooler.get_pool(self.cr.dbname).get('account.fiscalyear').browse(self.cr,self.uid,form['fiscalyear_id']).name
def get_account(self,form):
return pooler.get_pool(self.cr.dbname).get('account.account').browse(self.cr,self.uid,form['chart_account_id']).name
def get_start_period(self, form):
if form['filter'] == 'filter_period':
if form['period_from']:
return pooler.get_pool(self.cr.dbname).get('account.period').browse(self.cr,self.uid,form['period_from']).name
return ''
def get_end_period(self, form):
if form['filter'] == 'filter_period':
if form['period_to']:
return pooler.get_pool(self.cr.dbname).get('account.period').browse(self.cr,self.uid,form['period_to']).name
return ''
report_sxw.report_sxw('report.account.general.ledger', 'account.account', 'addons/account/report/general_ledger.rml', parser=general_ledger, header=False)
report_sxw.report_sxw('report.account.general.ledger_landscape', 'account.account', 'addons/account/report/general_ledger_landscape.rml', parser=general_ledger, header=False)