From 4c50c2b929c41e35ad994e0bf21b01da0fa87e5b Mon Sep 17 00:00:00 2001 From: "hda@tinyerp.com" <> Date: Tue, 21 Oct 2008 19:32:46 +0530 Subject: [PATCH] remove print bzr revid: hda@tinyerp.com-20081021140246-iwi29p5ngx4ixwmi --- addons/account/report/aged_trial_balance.py | 45 ++++------ .../report/general_ledger_landscape.py | 82 ++++++++----------- addons/account/report/third_party_ledger.py | 82 ++++++++----------- 3 files changed, 88 insertions(+), 121 deletions(-) diff --git a/addons/account/report/aged_trial_balance.py b/addons/account/report/aged_trial_balance.py index bd04138c8bf..ee7f5555ae9 100755 --- a/addons/account/report/aged_trial_balance.py +++ b/addons/account/report/aged_trial_balance.py @@ -31,13 +31,13 @@ import rml_parse from report import report_sxw class aged_trial_report(rml_parse.rml_parse): - + def __init__(self, cr, uid, name, context): super(aged_trial_report, self).__init__(cr, uid, name, context) self.line_query = '' self.total_account = [] - - + + self.localcontext.update({ 'time': time, 'get_lines': self._get_lines, @@ -46,19 +46,19 @@ class aged_trial_report(rml_parse.rml_parse): 'get_for_period': self._get_for_period, 'get_company': self._get_company, 'get_currency': self._get_currency, - + }) - - + + def _get_lines(self, form): - + if (form['result_selection'] == 'customer' ): self.ACCOUNT_TYPE = "('receivable')" elif (form['result_selection'] == 'supplier'): self.ACCOUNT_TYPE = "('payable')" else: self.ACCOUNT_TYPE = "('payable','receivable')" - + res = [] account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') @@ -78,7 +78,7 @@ class aged_trial_report(rml_parse.rml_parse): for i in range(7): self.total_account.append(0) # - + for partner in partners: values = {} ## If choise selection is in the future @@ -94,7 +94,7 @@ class aged_trial_report(rml_parse.rml_parse): "AND account_account.active", (form['date1'], partner['id'],form['date1'], form['company_id'])) before = self.cr.fetchone() - + self.total_account[6] = self.total_account[6] + (before and before[0] or 0.0) values['direction'] = before and before[0] or 0.0 @@ -112,7 +112,6 @@ class aged_trial_report(rml_parse.rml_parse): after = self.cr.fetchone() self.total_account[6] = self.total_account[6] + (after and after[0] or 0.0) values['direction'] = after and after[0] or "" - #print str(values['direction']) for i in range(5): self.cr.execute("SELECT SUM(debit-credit) " \ "FROM account_move_line AS line, account_account " \ @@ -128,8 +127,6 @@ class aged_trial_report(rml_parse.rml_parse): during = self.cr.fetchone() # Ajout du compteur self.total_account[(i)] = self.total_account[(i)] + (during and during[0] or 0) - - #print str(during) values[str(i)] = during and during[0] or "" self.cr.execute("SELECT SUM(debit-credit) " \ "FROM account_move_line AS line, account_account " \ @@ -145,19 +142,16 @@ class aged_trial_report(rml_parse.rml_parse): values['total'] = total and total[0] or 0.0 ## Add for total self.total_account[(i+1)] = self.total_account[(i+1)] + (total and total[0] or 0.0) - print self.total_account,">>>>>>>>>>>>>Total>>>>>>>>>>>>>>>>" values['name'] = partner['name'] #t = 0.0 #for i in range(5)+['direction']: # t+= float(values.get(str(i), 0.0) or 0.0) #values['total'] = t - + if values['total']: - res.append(values) - + total = 0.0 - totals = {} for r in res: total += float(r['total'] or 0.0) @@ -166,24 +160,17 @@ class aged_trial_report(rml_parse.rml_parse): totals[str(i)] += float(r[str(i)] or 0.0) return res - - - def _get_total(self,pos): - print self.total_account,"========_get_total========" period = self.total_account[int(pos)] - return period + return period - def _get_direction(self,pos): - period = self.total_account[int(pos)] - return period + return period def _get_for_period(self,pos): - period = self.total_account[int(pos)] - return period + return period def _get_company(self, form): return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).name @@ -194,5 +181,5 @@ class aged_trial_report(rml_parse.rml_parse): report_sxw.report_sxw('report.account.aged_trial_balance', 'res.partner', 'addons/account/report/aged_trial_balance.rml',parser=aged_trial_report,header=False) - + diff --git a/addons/account/report/general_ledger_landscape.py b/addons/account/report/general_ledger_landscape.py index f090b18c090..a091ec905dd 100755 --- a/addons/account/report/general_ledger_landscape.py +++ b/addons/account/report/general_ledger_landscape.py @@ -35,8 +35,8 @@ import pooler class general_ledger_landscape(rml_parse.rml_parse): _name = 'report.account.general.ledger_landscape' - - + + def preprocess(self, objects, data, ids): ## self.borne_date = self.get_min_date(data['form']) @@ -46,18 +46,18 @@ class general_ledger_landscape(rml_parse.rml_parse): new_ids = ids else: new_ids.append(data['form']['Account_list']) - + objects = self.pool.get('account.account').browse(self.cr, self.uid, new_ids) - - super(general_ledger_landscape, self).preprocess(objects, data, new_ids) - + + super(general_ledger_landscape, self).preprocess(objects, data, new_ids) + def __init__(self, cr, uid, name, context): super(general_ledger_landscape, self).__init__(cr, uid, name, context) self.query = "" self.child_ids = "" self.tot_currency = 0.0 self.period_sql = "" - self.sold_accounts = {} + self.sold_accounts = {} self.localcontext.update( { 'time': time, 'lines': self.lines, @@ -66,7 +66,7 @@ class general_ledger_landscape(rml_parse.rml_parse): 'sum_solde_account': self._sum_solde_account, 'sum_debit': self._sum_debit, 'sum_credit': self._sum_credit, - 'sum_solde': self._sum_solde, + 'sum_solde': self._sum_solde, 'get_children_accounts': self.get_children_accounts, 'sum_currency_amount_account': self._sum_currency_amount_account }) @@ -75,7 +75,7 @@ class general_ledger_landscape(rml_parse.rml_parse): result = {} #for id in ids: # result.setdefault(id, False) - + for account_line in self.pool.get('account.move.line').browse(cr, uid, ids, context): # For avoid long text in the field we will limit it to 5 lines # @@ -85,7 +85,7 @@ class general_ledger_landscape(rml_parse.rml_parse): num_id_move = str(account_line.move_id.id) num_id_line = str(account_line.id) account_id = str(account_line.account_id.id) - # search the basic account + # search the basic account # We have the account ID we will search all account move line from now until this time # We are in the case of we are on the top of the account move Line cr.execute('SELECT distinct(ac.code) as code_rest,ac.name as name_rest from account_account AS ac, account_move_line mv\ @@ -103,10 +103,8 @@ class general_ledger_landscape(rml_parse.rml_parse): result[account_line.id] = concat + '...' break rup_id+=1 - - #print str(result) return result - + def get_min_date(self,form): ## Get max born from account_fiscal year # @@ -123,9 +121,9 @@ class general_ledger_landscape(rml_parse.rml_parse): periods = form['periods'][0][2] if not periods: sql = """ - Select min(p.date_start) from account_period as p where p.fiscalyear_id = """ + str(form['fiscalyear']) + """ + Select min(p.date_start) from account_period as p where p.fiscalyear_id = """ + str(form['fiscalyear']) + """ """ - else: + else: periods_id = ','.join(map(str, periods)) sql = """ Select min(p.date_start) from account_period as p where p.id in ( """ + periods_id + """) @@ -141,30 +139,30 @@ class general_ledger_landscape(rml_parse.rml_parse): } return date_borne - - + + def get_children_accounts(self, account, form): - - + + self.child_ids = self.pool.get('account.account').search(self.cr, self.uid, [('parent_id', 'child_of', self.ids)]) -# +# res = [] ctx = self.context.copy() ## We will make the test for period or date ## We will now make the test # - if form.has_key('fiscalyear'): + if form.has_key('fiscalyear'): ctx['fiscalyear'] = form['fiscalyear'] ctx['periods'] = form['periods'][0][2] else: ctx['date_from'] = form['date_from'] ctx['date_to'] = form['date_to'] ## - + # self.query = self.pool.get('account.move.line')._query_get(self.cr, self.uid, context=ctx) - + for child_id in self.pool.get('account.account').search(self.cr, self.uid,[('parent_id', 'child_of', [account.id])]): child_account = self.pool.get('account.account').browse(self.cr, self.uid, child_id) sold_account = self._sum_solde_account(child_account,form) @@ -175,7 +173,6 @@ class general_ledger_landscape(rml_parse.rml_parse): [('account_id','=',child_account.id)], context=ctx)) <> 0 : res.append(child_account) - #print "Type de vue :" + form['display_account'] elif form['display_account'] == 'bal_solde': if child_account.type != 'view' \ and len(self.pool.get('account.move.line').search(self.cr, self.uid, @@ -183,7 +180,7 @@ class general_ledger_landscape(rml_parse.rml_parse): context=ctx)) <> 0 : if ( sold_account <> 0.0): res.append(child_account) - else: + else: if child_account.type != 'view' \ and len(self.pool.get('account.move.line').search(self.cr, self.uid, [('account_id','=',child_account.id)], @@ -205,17 +202,17 @@ class general_ledger_landscape(rml_parse.rml_parse): sum_credit = 0 else: sum_credit = resultat[0]['sum_credit'] - + move.init_credit = sum_credit move.init_debit = sum_debit - + else: move.init_credit = 0 move.init_debit = 0 - + ## return res - + def lines(self, account, form): inv_types = { 'out_invoice': 'CI: ', @@ -229,9 +226,9 @@ class general_ledger_landscape(rml_parse.rml_parse): else: sorttag = 'j.code' sql = """ - SELECT l.id, l.date, j.code,c.code AS currency_code,l.amount_currency,l.ref, l.name, l.debit, l.credit, l.period_id + SELECT l.id, l.date, j.code,c.code AS currency_code,l.amount_currency,l.ref, l.name, l.debit, l.credit, l.period_id FROM account_move_line l LEFT JOIN res_currency c on (l.currency_id=c.id) JOIN account_journal j on (l.journal_id=j.id) - AND account_id = %d AND %s + AND account_id = %d AND %s ORDER by %s"""%(account.id,self.query,sorttag) self.cr.execute(sql) res = self.cr.dictfetchall() @@ -258,11 +255,11 @@ class general_ledger_landscape(rml_parse.rml_parse): if (l['credit'] > 0): if l['amount_currency'] != None: l['amount_currency'] = abs(l['amount_currency']) * -1 - + # if l['amount_currency'] != None: - self.tot_currency = self.tot_currency + l['amount_currency'] - + self.tot_currency = self.tot_currency + l['amount_currency'] + return res def _sum_debit_account(self, account, form): @@ -291,7 +288,7 @@ class general_ledger_landscape(rml_parse.rml_parse): sum_credit += account.init_credit # ## - + return sum_credit def _sum_solde_account(self, account, form): @@ -301,7 +298,7 @@ class general_ledger_landscape(rml_parse.rml_parse): sum_solde = self.cr.fetchone()[0] or 0.0 if form['soldeinit']: sum_solde += account.init_debit - account.init_credit - + return sum_solde def _sum_debit(self, form): @@ -330,31 +327,24 @@ class general_ledger_landscape(rml_parse.rml_parse): self.cr.execute("SELECT (sum(debit) - sum(credit)) as tot_solde "\ "FROM account_move_line l "\ "WHERE l.account_id in ("+','.join(map(str, self.child_ids))+") AND "+self.query) -# print ("SELECT (sum(debit) - sum(credit)) as Test "\ -# "FROM account_move_line l "\ -# "WHERE l.account_id in ("+','.join(map(str, child_ids))+") AND "+query+period_sql) sum_solde = self.cr.fetchone()[0] or 0.0 return sum_solde - + def _set_get_account_currency_code(self, account_id): - print"====account_id=====",account_id self.cr.execute("SELECT c.code as code "\ "FROM res_currency c,account_account as ac "\ "WHERE ac.id = %s AND ac.currency_id = c.id"%(account_id)) result = self.cr.fetchone() - print"====result====",result if result: self.account_currency = result[0] else: self.account_currency = False - - + def _sum_currency_amount_account(self, account, form): - self._set_get_account_currency_code(account.id) self.cr.execute("SELECT sum(aml.amount_currency) FROM account_move_line as aml,res_currency as rc WHERE aml.currency_id = rc.id AND aml.account_id= %d "%account.id) total = self.cr.fetchone() - + if self.account_currency: return_field = str(total[0]) + self.account_currency return return_field diff --git a/addons/account/report/third_party_ledger.py b/addons/account/report/third_party_ledger.py index 6d7f7a9bf16..194e18d1d53 100755 --- a/addons/account/report/third_party_ledger.py +++ b/addons/account/report/third_party_ledger.py @@ -59,7 +59,7 @@ class third_party_ledger(rml_parse.rml_parse): for date in date_array: full_str_date.append(str(date)) return full_str_date - + # def transform_period_into_date_array(self,data): ## Get All Period Date @@ -67,66 +67,61 @@ class third_party_ledger(rml_parse.rml_parse): periods_id = self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id','=',data['form']['fiscalyear'])]) else: periods_id = data['form']['periods'][0][2] - date_array = [] + date_array = [] for period_id in periods_id: period_obj = self.pool.get('account.period').browse(self.cr, self.uid, period_id) date_array = date_array + self.date_range(period_obj.date_start,period_obj.date_stop) self.date_lst = date_array self.date_lst.sort() - + def transform_date_into_date_array(self,data): return_array = self.date_range(data['form']['date1'],data['form']['date2']) self.date_lst = return_array self.date_lst.sort() def transform_both_into_date_array(self,data): - + if not data['form']['periods'][0][2] : periods_id = self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id','=',data['form']['fiscalyear'])]) else: periods_id = data['form']['periods'][0][2] - date_array = [] + date_array = [] for period_id in periods_id: period_obj = self.pool.get('account.period').browse(self.cr, self.uid, period_id) date_array = date_array + self.date_range(period_obj.date_start,period_obj.date_stop) - + period_start_date = date_array[0] date_start_date = data['form']['date1'] period_stop_date = date_array[-1] date_stop_date = data['form']['date2'] - + if period_start_date