diff --git a/account_financial_report/model/account_financial_report.py b/account_financial_report/model/account_financial_report.py index b1e50d68..2c593a24 100644 --- a/account_financial_report/model/account_financial_report.py +++ b/account_financial_report/model/account_financial_report.py @@ -48,6 +48,7 @@ class account_financial_report(osv.osv): 'period_ids': fields.many2many('account.period', 'afr_period_rel', 'afr_id', 'period_id', 'Periods', help='All periods in the fiscal year if empty'), 'analytic_ledger': fields.boolean('Analytic Ledger', help="Allows to Generate an Analytic Ledger for accounts with moves. Available when Balance Sheet and 'Initial | Debit | Credit | YTD' are selected"), + 'journal_ledger': fields.boolean('journal Ledger', help="Allows to Generate an journal Ledger for accounts with moves. Available when Balance Sheet and 'Initial | Debit | Credit | YTD' are selected"), 'tot_check': fields.boolean('Summarize?', help='Checking will add a new line at the end of the Report which will Summarize Columns in Report'), 'lab_str': fields.char('Description', help='Description for the Summary', size=128), diff --git a/account_financial_report/report/balance_full_4_cols_journal_ledger.rml b/account_financial_report/report/balance_full_4_cols_journal_ledger.rml new file mode 100644 index 00000000..1ae239b9 --- /dev/null +++ b/account_financial_report/report/balance_full_4_cols_journal_ledger.rml @@ -0,0 +1,398 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [[setLang(user.lang)]] + + + + + + CODE + + + + ACCOUNT + + + INITIAL + + + DEBIT + + + CREDIT + + + BALANCE + + + + + + + + + DATE + + + + + PERIOD + + + + JOURNAL ENTRY + + + + + + + + + + + + + + + + + + +
+ [[ repeatIn([x for x in lines(data['form']) if x['type'] != 'view'], 'a') ]] + + + + + [[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier-Bold"}) or removeParentNode('font') ]] + [[a['label']==True and a['code'] or '' ]] + + + + + [[ ((a['total'] and not a['label']) and setTag('para','para',{'alignment':"RIGHT"}) or (a['type']<>'view' and setTag('para','para',{'fontName':"Courier-Bold"}))) or removeParentNode('font') ]] + [[ a['type']=='view' and a['name'].upper() or a['name'].title() ]] + + + + + [[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier-Bold"}) or removeParentNode('font') ]] + [[ (a['total']==True) and formatLang(a['balanceinit'] and a['balanceinit'] * a.get('change_sign',1.0) or 0.0, digits=2, grouping=True) or '']] + + + + + [[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier-Bold"}) or removeParentNode('font') ]] + [[ (a['total']==True) and formatLang(a['debit'], digits=2, grouping=True) or '']] + + + + + [[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier-Bold"}) or removeParentNode('font') ]] + [[ (a['total']==True) and formatLang(a['credit'], digits=2, grouping=True) or '']] + + + + + [[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier-Bold"}) or removeParentNode('font') ]] + [[ (a['total']==True) and formatLang(a['balance'] and a['balance'] * a.get('change_sign',1.0) or 0.0, digits=2, grouping=True) or '']] + + + + + +
+ [[ repeatIn(a['journal'], 'j') ]] + + + + + + [[ formatLang( j['date'], date=True) ]] + + + + + [[ j['period'] ]] + + + + + [[ j['name'] ]] + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ [[ repeatIn(j.get('obj').line_id, 'k') ]] + + + + + [[ k.account_id.code == a['code'] and k.name or removeParentNode('blockTable') ]] + + + + + [[ 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.account_id.type<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]] + [[ k.debit and formatLang(k.debit, digits=2, grouping=True) or '' ]] + + + + + [[ k.account_id.type<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]] + [[ k.credit and formatLang(k.credit, digits=2, grouping=True) or '' ]] + + + + + [[ k.account_id.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 '']] + + + + + + + + + [[ k.account_id.code != a['code'] and k.name or removeParentNode('blockTable') ]] + + + + + [[ 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.account_id.type<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]] + [[ k.debit and formatLang(k.debit, digits=2, grouping=True) or '' ]] + + + + + [[ k.account_id.type<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]] + [[ k.credit and formatLang(k.credit, digits=2, grouping=True) or '' ]] + + + + + [[ k.account_id.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 9ea487f2..804a4650 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -239,6 +239,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 @@ -786,6 +826,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'] = [] @@ -895,6 +937,12 @@ report_sxw.report_sxw('report.afr.analytic.ledger', 'account_financial_report/report/balance_full_4_cols_analytic_ledger.rml', parser=account_balance, header=False) + +report_sxw.report_sxw('report.afr.journal.ledger', + 'wizard.report', + 'account_financial_report/report/balance_full_4_cols_journal_ledger.rml', + parser=account_balance, + header=False) report_sxw.report_sxw('report.afr.5cols', 'wizard.report', @@ -913,3 +961,4 @@ report_sxw.report_sxw('report.afr.13cols', 'account_financial_report/report/balance_full_13_cols.rml', parser=account_balance, header=False) + diff --git a/account_financial_report/view/account_financial_report_view.xml b/account_financial_report/view/account_financial_report_view.xml index 6306ba76..b5669771 100644 --- a/account_financial_report/view/account_financial_report_view.xml +++ b/account_financial_report/view/account_financial_report_view.xml @@ -25,6 +25,15 @@ attrs="{'readonly':['|',('columns','!=','four'),('inf_type','!=','BS')],}" on_change='onchange_analytic_ledger(company_id,analytic_ledger)' /> + + + + + diff --git a/account_financial_report/view/report.xml b/account_financial_report/view/report.xml index 3d932a97..e97d73ce 100644 --- a/account_financial_report/view/report.xml +++ b/account_financial_report/view/report.xml @@ -45,6 +45,17 @@ string="Analytic Ledger" header="False" /> + + + + diff --git a/account_financial_report/view/wizard.xml b/account_financial_report/view/wizard.xml index 76deeaff..040e6d43 100644 --- a/account_financial_report/view/wizard.xml +++ b/account_financial_report/view/wizard.xml @@ -41,6 +41,9 @@ attrs="{'readonly':['|',('columns','!=','four'),('inf_type','!=','BS')],}" on_change='onchange_analytic_ledger(company_id,analytic_ledger)' /> + diff --git a/account_financial_report/wizard/wizard.py b/account_financial_report/wizard/wizard.py index b15d54f2..43bd6895 100644 --- a/account_financial_report/wizard/wizard.py +++ b/account_financial_report/wizard/wizard.py @@ -50,6 +50,7 @@ class wizard_report(osv.osv_memory): 'periods': fields.many2many('account.period', 'rel_wizard_period', 'wizard_id', 'period_id', 'Periods', help='All periods in the fiscal year if empty'), 'analytic_ledger': fields.boolean('Analytic Ledger', help="Allows to Generate an Analytic Ledger for accounts with moves. Available when Balance Sheet and 'Initial | Debit | Credit | YTD' are selected"), + 'journal_ledger': fields.boolean('Journal Ledger', help="Allows to Generate an Journal Ledger for accounts with moves. Available when Balance Sheet and 'Initial | Debit | Credit | YTD' are selected"), 'tot_check': fields.boolean('Summarize?', help='Checking will add a new line at the end of the Report which will Summarize Columns in Report'), 'lab_str': fields.char('Description', help='Description for the Summary', size=128), @@ -273,6 +274,8 @@ class wizard_report(osv.osv_memory): if data['form']['columns'] == 'four': if data['form']['analytic_ledger'] and data['form']['inf_type'] == 'BS': name = 'afr.analytic.ledger' + elif data['form']['journal_ledger'] and data['form']['inf_type'] == 'BS': + name = 'afr.journal.ledger' else: name = 'afr.4cols' if data['form']['columns'] == 'five':