[IMP] Account: Profit and loss and balance sheet report improved

bzr revid: mra@mra-laptop-20100802044243-pu0zd89pip6o0f80
This commit is contained in:
Mustufa Rangwala
2010-08-02 10:12:43 +05:30
parent 2152922daa
commit cb4c39c5a6
7 changed files with 88 additions and 43 deletions
+2 -2
View File
@@ -32,7 +32,7 @@ class account_balance(report_sxw.rml_parse, common_report_header):
if (data['model'] == 'ir.ui.menu'):
new_ids = 'chart_account_id' in data['form'] and [data['form']['chart_account_id']] or []
objects = self.pool.get('account.account').browse(self.cr, self.uid, new_ids)
self.query_get_clause = data['form']['query_line'] or ''
self.query_get_clause = data['form'].get('query_line', False) or ''
return super(account_balance, self).set_context(objects, data, new_ids, report_type=report_type)
def __init__(self, cr, uid, name, context=None):
@@ -65,7 +65,7 @@ class account_balance(report_sxw.rml_parse, common_report_header):
if data['model']=='account.account':
return self.pool.get('account.account').browse(self.cr, self.uid, data['form']['id']).company_id.name
return super(account_balance ,self)._get_account(data)
def lines(self, form, ids=[], done=None, level=1):
obj_account = self.pool.get('account.account')
if not ids:
+28 -26
View File
@@ -34,7 +34,7 @@ class report_balancesheet_horizontal(rml_parse.rml_parse, common_report_header):
self.result_sum_dr = 0.0
self.result_sum_cr = 0.0
self.result = {}
self.res_pl = {}
self.res_bl = {}
self.result_temp = []
self.localcontext.update({
'time': time,
@@ -55,26 +55,27 @@ class report_balancesheet_horizontal(rml_parse.rml_parse, common_report_header):
'get_filter': self._get_filter,
'get_journal': self._get_journal,
'get_start_date':self._get_start_date,
'get_end_date':self._get_end_date,
'get_company':self._get_company,
'get_end_date':self._get_end_date,
'get_company':self._get_company,
})
self.context = context
def get_abs(self,amount):
return abs(amount)
def sum_dr(self):
if self.res_pl['type'] == 'Net Profit':
self.result_sum_dr += self.res_pl['balance']
if self.res_bl['type'] == 'Net Profit':
self.result_sum_dr += self.res_bl['balance']
return self.result_sum_dr or 0.0
def sum_cr(self):
if self.res_pl['type'] == 'Net Loss':
self.result_sum_cr += self.res_pl['balance']
if self.res_bl['type'] == 'Net Loss':
self.result_sum_cr += self.res_bl['balance']
return self.result_sum_cr or 0.0
def get_pl_balance(self):
return self.res_pl or 0.0
return self.res_bl or 0.0
def get_data(self,data):
cr, uid = self.cr, self.uid
@@ -82,7 +83,7 @@ class report_balancesheet_horizontal(rml_parse.rml_parse, common_report_header):
#Getting Profit or Loss Balance from profit and Loss report
result_pl=self.obj_pl.get_data(data)
self.res_pl=self.obj_pl.final_result()
self.res_bl = self.obj_pl.final_result()
type_pool = db_pool.get('account.account.type')
account_pool = db_pool.get('account.account')
@@ -95,31 +96,30 @@ class report_balancesheet_horizontal(rml_parse.rml_parse, common_report_header):
ctx = self.context.copy()
# ctx['state'] = form['context'].get('state','filter_no')
ctx['fiscalyear'] = data['form']['fiscalyear_id']
ctx['fiscalyear'] = data['form'].get('fiscalyear_id', False)
if data['form']['filter']=='filter_period' :
ctx['periods'] = data['form']['periods']
elif data['form']['filter']== 'filter_date':
ctx['date_from'] = data['form']['date_from']
ctx['date_to'] = data['form']['date_to']
if data['form']['filter'] == 'filter_period' :
ctx['periods'] = data['form'].get('periods', False)
elif data['form']['filter'] == 'filter_date':
ctx['date_from'] = data['form'].get('date_from', False)
ctx['date_to'] = data['form'].get('date_to', False)
cal_list={}
cal_list = {}
pl_dict = {}
account_dict = {}
account_id = data['form']['chart_account_id']
account_id = data['form'].get('chart_account_id', False)
account_ids = account_pool._get_children_and_consol(cr, uid, account_id, context=ctx)
accounts = account_pool.browse(cr, uid, account_ids, context=ctx)
if self.res_pl['type'] == 'Net Profit C.F.B.L.':
self.res_pl['type'] = 'Net Profit'
if self.res_bl['type'] == 'Net Profit C.F.B.L.':
self.res_bl['type'] = 'Net Profit'
else:
self.res_pl['type'] = 'Net Loss'
self.res_bl['type'] = 'Net Loss'
pl_dict = {
'code' : False,
'name' : self.res_pl['type'],
'name' : self.res_bl['type'],
'level': False,
'balance':self.res_pl['balance'],
'balance':self.res_bl['balance'],
}
for typ in types:
accounts_temp = []
@@ -140,7 +140,7 @@ class report_balancesheet_horizontal(rml_parse.rml_parse, common_report_header):
if account.credit > 0 or account.debit > 0 or account.balance > 0 :
accounts_temp.append(account_dict)
elif data['form']['display_account'] == 'bal_solde':
if account.balance != 0:
if account.balance != 0:
accounts_temp.append(account_dict)
else:
accounts_temp.append(account_dict)
@@ -152,7 +152,7 @@ class report_balancesheet_horizontal(rml_parse.rml_parse, common_report_header):
cal_list[typ]=self.result[typ]
if cal_list:
temp={}
temp = {}
for i in range(0,max(len(cal_list['liability']),len(cal_list['asset']))):
if i < len(cal_list['liability']) and i < len(cal_list['asset']):
temp={
@@ -206,3 +206,5 @@ report_sxw.report_sxw('report.account.balancesheet.horizontal', 'account.account
report_sxw.report_sxw('report.account.balancesheet', 'account.account',
'addons/account/report/report_balance_sheet.rml',parser=report_balancesheet_horizontal,
header='internal')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+9 -7
View File
@@ -56,6 +56,7 @@ class report_pl_account_horizontal(rml_parse.rml_parse, common_report_header):
'get_company':self._get_company,
})
self.context = context
def get_abs(self,amount):
return abs(amount)
@@ -86,16 +87,16 @@ class report_pl_account_horizontal(rml_parse.rml_parse, common_report_header):
]
ctx = self.context.copy()
ctx['fiscalyear'] = data['form']['fiscalyear_id']
ctx['fiscalyear'] = data['form'].get('fiscalyear_id', False)
if data['form']['filter']=='filter_period' :
ctx['periods'] = data['form']['periods']
elif data['form']['filter']== 'filter_date':
ctx['date_from'] = data['form']['date_from']
ctx['date_to'] = data['form']['date_to']
if data['form']['filter'] == 'filter_period' :
ctx['periods'] = data['form'].get('periods', False)
elif data['form']['filter'] == 'filter_date':
ctx['date_from'] = data['form'].get('date_from', False)
ctx['date_to'] = data['form'].get('date_to', False)
cal_list = {}
account_id = data['form']['chart_account_id']
account_id = data['form'].get('chart_account_id', False)
account_ids = account_pool._get_children_and_consol(cr, uid, account_id, context=ctx)
accounts = account_pool.browse(cr, uid, account_ids, context=ctx)
@@ -177,3 +178,4 @@ report_sxw.report_sxw('report.pl.account.horizontal', 'account.account',
report_sxw.report_sxw('report.pl.account', 'account.account',
'addons/account/report/report_pl_account.rml',parser=report_pl_account_horizontal, header='internal')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -19,6 +19,8 @@
#
##############################################################################
from lxml import etree
from osv import osv
class account_balance_report(osv.osv_memory):
@@ -26,9 +28,24 @@ class account_balance_report(osv.osv_memory):
_name = 'account.balance.report'
_description = 'Account Balance Report'
_defaults = {
'journal_ids': [],
}
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
mod_obj = self.pool.get('ir.model.data')
res = super(account_balance_report, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=False)
doc = etree.XML(res['arch'])
nodes = doc.xpath("//field[@name='journal_ids']")
for node in nodes:
node.set('readonly', '1')
node.set('required', '0')
res['arch'] = etree.tostring(doc)
return res
def _print_report(self, cr, uid, ids, data, query_line, context=None):
data = self.pre_print_report(cr, uid, ids, data, query_line, context=context)
return {'type': 'ir.actions.report.xml', 'report_name': 'account.account.balance', 'datas': data, 'nodestroy':True,}
return {'type': 'ir.actions.report.xml', 'report_name': 'account.account.balance', 'datas': data}
account_balance_report()
@@ -19,6 +19,8 @@
#
##############################################################################
from lxml import etree
from osv import osv, fields
class account_bs_report(osv.osv_memory):
@@ -37,8 +39,20 @@ class account_bs_report(osv.osv_memory):
_defaults={
'display_type': True,
'journal_ids': [],
}
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
mod_obj = self.pool.get('ir.model.data')
res = super(account_bs_report, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=False)
doc = etree.XML(res['arch'])
nodes = doc.xpath("//field[@name='journal_ids']")
for node in nodes:
node.set('readonly', '1')
node.set('required', '0')
res['arch'] = etree.tostring(doc)
return res
def _print_report(self, cr, uid, ids, data, query_line, context=None):
if context is None:
context = {}
@@ -49,14 +63,12 @@ class account_bs_report(osv.osv_memory):
'type': 'ir.actions.report.xml',
'report_name': 'account.balancesheet.horizontal',
'datas': data,
'nodestroy':True,
}
else:
return {
'type': 'ir.actions.report.xml',
'report_name': 'account.balancesheet',
'datas': data,
'nodestroy':True,
}
account_bs_report()
@@ -54,7 +54,7 @@ class account_report_general_ledger(osv.osv_memory):
if not data['form']['fiscalyear_id']:# GTK client problem onchange does not consider in save record
data['form'].update({'initial_balance': False})
if data['form']['landscape']:
return { 'type': 'ir.actions.report.xml', 'report_name': 'account.general.ledger_landscape', 'datas': data, 'nodestroy':True }
return { 'type': 'ir.actions.report.xml', 'report_name': 'account.general.ledger_landscape', 'datas': data}
return { 'type': 'ir.actions.report.xml', 'report_name': 'account.general.ledger', 'datas': data}
account_report_general_ledger()
@@ -19,6 +19,8 @@
#
##############################################################################
from lxml import etree
from osv import osv, fields
class account_pl_report(osv.osv_memory):
@@ -34,8 +36,20 @@ class account_pl_report(osv.osv_memory):
_defaults = {
'display_type': True,
'journal_ids': [],
}
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
mod_obj = self.pool.get('ir.model.data')
res = super(account_pl_report, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=False)
doc = etree.XML(res['arch'])
nodes = doc.xpath("//field[@name='journal_ids']")
for node in nodes:
node.set('readonly', '1')
node.set('required', '0')
res['arch'] = etree.tostring(doc)
return res
def _print_report(self, cr, uid, ids, data, query_line, context=None):
if context is None:
context = {}
@@ -46,15 +60,13 @@ class account_pl_report(osv.osv_memory):
'type': 'ir.actions.report.xml',
'report_name': 'pl.account.horizontal',
'datas': data,
'nodestroy':True,
}
}
else:
return {
'type': 'ir.actions.report.xml',
'report_name': 'pl.account',
'datas': data,
'nodestroy':True,
}
}
account_pl_report()