1 # -*- encoding: utf-8 -*-
2 ##############################################################################
4 # Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
6 # WARNING: This program as such is intended to be used by professional
7 # programmers who take the whole responsability of assessing all potential
8 # consequences resulting from its eventual inadequacies and bugs
9 # End users who are looking for a ready-to-use solution with commercial
10 # garantees and support are strongly adviced to contract a Free Software
13 # This program is Free Software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License
15 # as published by the Free Software Foundation; either version 2
16 # of the License, or (at your option) any later version.
18 # This program is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU General Public License for more details.
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write to the Free Software
25 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 ##############################################################################
32 from report import report_sxw
34 #from addons.account.wizard import wizard_account_balance_report
43 class account_report_bs(report_sxw.rml_parse):
44 def __init__(self, cr, uid, name, context):
45 super(account_report_bs, self).__init__(cr, uid, name, context)
46 self.localcontext.update({
50 self.context = context
53 def line_total(self,line_id,ctx):
55 bsline= self.pool.get('account.report.bs').browse(self.cr,self.uid,[line_id])[0]
56 bsline_accids = bsline.account_id
57 res =self.pool.get('account.report.bs').read(self.cr,self.uid,[line_id],['account_id','child_id'])[0]
58 for acc_id in res['account_id']:
59 acc = self.pool.get('account.account').browse(self.cr,self.uid,[acc_id],ctx)[0]
61 bsline_reportbs = res['child_id']
63 for report in bsline_reportbs:
64 _total +=self.line_total(report,ctx)
67 def lines(self, form, ids={}, done=None, level=1):
75 ctx = self.context.copy()
76 ctx['fiscalyear'] = form['fiscalyear']
77 ctx['periods'] = form['periods'][0][2]
78 report_objs = self.pool.get('account.report.bs').browse(self.cr, self.uid, ids)
81 title_name = report_objs[0].name
83 return cmp(x.code, y.code)
84 report_objs.sort(cmp_code)
86 for report_obj in report_objs:
87 if report_obj.id in done:
89 done[report_obj.id] = 1
92 if report_obj.color_font:
93 color_font = report_obj.color_font.name
94 if report_obj.color_back:
95 color_back = report_obj.color_back.name
98 'code': report_obj.code,
99 'name': report_obj.name,
101 'balance': self.line_total(report_obj.id,ctx),
102 'color_font':color_font,
103 'color_back':color_back,
104 'font_style' : report_obj.font_style
107 report_type = report_obj.report_type
108 if report_type != 'only_obj':
109 account_ids = self.pool.get('account.report.bs').read(self.cr,self.uid,[report_obj.id],['account_id'])[0]['account_id']
110 for account_id in account_ids:
111 res1 = self.check_child_id(account_id,level,ctx,report_type)
114 if report_obj.child_id:
115 ids2 = [(x.code,x.id) for x in report_obj.child_id]
117 result += self.lines(form, [x[1] for x in ids2], done, level+1)
121 def check_child_id(self,account_id,level,ctx,report_type):
122 account = self.pool.get('account.account').browse(self.cr,self.uid,[account_id],ctx)[0]
125 'code': account.code,
126 'name': account.name,
128 'balance': account.balance,
129 'color_font' : 'black',
130 'color_back' :'pink',
131 'font_style' : 'Helvetica-BoldOblique',
134 if report_type != 'with_account':
135 acc_child_id = self.pool.get('account.account').search(self.cr,self.uid,[('parent_id','=',[account_id]),('type','=','view')])
136 for child_id in acc_child_id :
137 result += self.check_child_id(child_id,level+1,ctx,report_type)
142 # def _sum_credit(self):
143 # return self.sum_credit
145 # def _sum_debit(self):
146 # return self.sum_debit
147 report_sxw.report_sxw('report.account.report.bs', 'account.report.bs', 'addons/account_reporting/report/account_report_bs.rml', parser=account_report_bs)
148 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: