From ad65abc6db691faf625873434c8b9f57843d4fa3 Mon Sep 17 00:00:00 2001 From: "Fernando.rangel" Date: Sat, 27 Jul 2013 17:18:28 -0700 Subject: [PATCH] [ADD][balance_full_4_cols_journal_ledger] add boolean field " journal ledger" and its report --- ...=> balance_full_4_cols_journal_ledger.rml} | 115 +++++++++++++----- account_financial_report/report/parser.py | 42 +++++++ account_financial_report/view/wizard.xml | 1 - 3 files changed, 124 insertions(+), 34 deletions(-) rename account_financial_report/report/{balance_full_cols_journal_ledger.rml => balance_full_4_cols_journal_ledger.rml} (72%) diff --git a/account_financial_report/report/balance_full_cols_journal_ledger.rml b/account_financial_report/report/balance_full_4_cols_journal_ledger.rml similarity index 72% rename from account_financial_report/report/balance_full_cols_journal_ledger.rml rename to account_financial_report/report/balance_full_4_cols_journal_ledger.rml index 8852974f..1ce10614 100644 --- a/account_financial_report/report/balance_full_cols_journal_ledger.rml +++ b/account_financial_report/report/balance_full_4_cols_journal_ledger.rml @@ -89,6 +89,20 @@ alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> + + [[setLang(user.lang)]] - + CODE @@ -145,8 +159,7 @@ - - + @@ -162,13 +175,13 @@ - REFERENCE + JOURNAL ENTRY - JOURNAL ENTRY + - PARTNER + @@ -181,11 +194,6 @@ - - - - -
[[ repeatIn([x for x in lines(data['form']) if x['type'] != 'view'], 'a') ]] @@ -230,62 +238,103 @@
- [[ repeatIn(a['mayor'], 'm') ]] - + [[ repeatIn(a['journal'], 'j') ]] + - - [[ formatLang( m['date'], date=True) ]] + + [[ formatLang( j['date'], date=True) ]] - - [[ m['period'] ]] + + [[ j['period'] ]] - - [[ m['name'] ]] [[ m['ref'] and (' - Ref %s'%m['ref']) or '' ]] + + [[ j['name'] ]] - - [[ m['entry'] ]] + + - + - [[ m['partner'] ]] + - [[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]] - [[ (a['total']==True) and formatLang(m['debit'], digits=2, grouping=True) or '']] - [[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]] - [[ (a['total']==True) and formatLang(m['credit'], digits=2, grouping=True) or '']] - [[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]] - [[ (a['total']==True) and formatLang(m['balance'] and m['balance'] * a.get('change_sign',1.0) or 0.0, digits=2, grouping=True) or '']] +
+ [[ repeatIn(j.get('obj').line_id, 'k') ]] + + + + + [[ k.name ]] + + + + + [[ k.ref and k.ref or '']] + + + + + [[ k.partner_id and k.partner_id.name or '']] + + + + + [[ k.account_id and k.account_id.code or '']] + + + + + [[ k.account_id and k.account_id.name or '']] + + + + + [[ k.type<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]] + [[ k.debit and formatLang(k.debit, digits=2, grouping=True) or '' ]] + + + + + [[ k.type<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]] + [[ k.credit and formatLang(k.credit, digits=2, grouping=True) or '' ]] + + + + + [[ k.type<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]] + [[ k.reconcile_id and k.reconcile_id.name or k.reconcile_partial_id and k.reconcile_partial_id.name or '']] + + + + +
+
diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index c68c5d2c..a1425c68 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -220,6 +220,46 @@ class account_balance(report_sxw.rml_parse): }) return res + def _get_journal_ledger(self, account, ctx={}): + res = [] + am_obj = self.pool.get('account.move') + print 'AM OBJ ', am_obj + if account['type'] in ('other', 'liquidity', 'receivable', 'payable'): + #~ TODO: CUANDO EL PERIODO ESTE VACIO LLENARLO CON LOS PERIODOS DEL EJERCICIO + #~ FISCAL, SIN LOS PERIODOS ESPECIALES + periods = ', '.join([str(i) for i in ctx['periods']]) + #~ periods = str(tuple(ctx['periods'])) + where = """where aml.period_id in (%s) and aa.id = %s and aml.state <> 'draft'""" % ( + periods, account['id']) + if ctx.get('state','posted')=='posted': + where += "AND am.state = 'posted'" + sql_detalle = """SELECT + DISTINCT am.id as am_id, + aj.name as diario, + am.name as name, + am.date as date, + ap.name as periodo + from account_move_line aml + inner join account_journal aj on aj.id = aml.journal_id + inner join account_account aa on aa.id = aml.account_id + inner join account_period ap on ap.id = aml.period_id + inner join account_move am on am.id = aml.move_id """ + where +\ + """ order by date, am.name""" + + self.cr.execute(sql_detalle) + resultat = self.cr.dictfetchall() + for det in resultat: + res.append({ + 'am_id': det['am_id'], + 'journal': det['diario'], + 'name': det['name'], + 'date': det['date'], + 'period': det['periodo'], + 'obj': am_obj.browse(self.cr,self.uid,det['am_id']) + }) + print 'ACCOUNT NAME', am_obj.browse(self.cr,self.uid,det['am_id']).name + return res + def lines(self, form, level=0): """ Returns all the data needed for the report lines @@ -766,6 +806,8 @@ class account_balance(report_sxw.rml_parse): #~ ANALYTIC LEDGER if to_include and form['analytic_ledger'] and form['columns'] == 'four' and form['inf_type'] == 'BS' and res['type'] in ('other', 'liquidity', 'receivable', 'payable'): res['mayor'] = self._get_analytic_ledger(res, ctx=ctx_end) + elif to_include and form['journal_ledger'] and form['columns'] == 'four' and form['inf_type'] == 'BS' and res['type'] in ('other', 'liquidity', 'receivable', 'payable'): + res['journal'] = self._get_journal_ledger(res, ctx=ctx_end) else: res['mayor'] = [] diff --git a/account_financial_report/view/wizard.xml b/account_financial_report/view/wizard.xml index 46bd682a..040e6d43 100644 --- a/account_financial_report/view/wizard.xml +++ b/account_financial_report/view/wizard.xml @@ -43,7 +43,6 @@ />