diff --git a/addons/account/report/account_journal.rml b/addons/account/report/account_journal.rml index d98a8cc1152..3eb130ba160 100644 --- a/addons/account/report/account_journal.rml +++ b/addons/account/report/account_journal.rml @@ -268,7 +268,7 @@ [[ formatLang(sum_debit(o.period_id.id, o.journal_id.id)) ]] [[ formatLang(sum_credit(o.period_id.id, o.journal_id.id)) ]] - [[ formatLang((sum_debit(o.period_id.id, o.journal_id.id) - sum_credit(o.period_id.id, o.journal_id.id))) ]] + [[ formatLang((sum_credit(o.period_id.id, o.journal_id.id) - sum_debit(o.period_id.id, o.journal_id.id))) ]] [[ repeatIn(lines(o.period_id.id, o.journal_id.id), 'line') ]][[ formatLang(line.date,date=True) ]] @@ -283,7 +283,7 @@ - [[ get_currency(data) or removeParentNode('blockTable') ]] + [[ display_currency(data) or removeParentNode('blockTable') ]] Date Voucher No diff --git a/addons/account/report/general_journal.py b/addons/account/report/general_journal.py index 94178afa5c9..b64bfb9c19f 100644 --- a/addons/account/report/general_journal.py +++ b/addons/account/report/general_journal.py @@ -84,15 +84,15 @@ class journal_print(report_sxw.rml_parse, common_report_header): def lines(self, period_id, journal_id=[]): if not self.journal_ids: return [] - self.cr.execute('SELECT j.code, j.name, l.amount_currency,c.code AS currency_code, ' + self.cr.execute('SELECT j.code, j.name, l.amount_currency,c.code AS currency_code,l.currency_id , ' 'SUM(l.debit) AS debit, SUM(l.credit) AS credit ' 'FROM account_move_line l ' 'LEFT JOIN account_journal j ON (l.journal_id=j.id) ' 'LEFT JOIN res_currency c on (l.currency_id=c.id)' 'WHERE period_id=%s AND journal_id IN %s '+self.query_get_clause +'' - 'GROUP BY j.id, j.code, j.name, l.amount_currency,c.code ', + 'GROUP BY j.id, j.code, j.name, l.amount_currency,c.code,l.currency_id ', (period_id, tuple(self.journal_ids))) - + return self.cr.dictfetchall() def _set_get_account_currency_code(self, account_id): self.cr.execute("SELECT c.code as code "\ diff --git a/addons/account/report/general_journal.rml b/addons/account/report/general_journal.rml index 71e47f40d6e..6fb59d10c5f 100644 --- a/addons/account/report/general_journal.rml +++ b/addons/account/report/general_journal.rml @@ -314,7 +314,7 @@ [[ formatLang(line['credit']) ]] - [[ formatLang(line['debit']-line['debit'] ) ]] + [[ formatLang(line['credit']-line['debit'] ) ]] @@ -324,8 +324,8 @@ [[ line['name'] ]] [[ formatLang(line['debit'] )]] [[ formatLang(line['credit']) ]] - [[ formatLang(line['debit']-line['debit'] ) ]] - [[ formatLang(line['amount_currency'] or '') ]] [[ line['currency_code'] or '' ]] + [[ formatLang(line['credit']-line['debit'] ) ]] + [[ line['currency_id'] and formatLang(line['amount_currency'] ) ]] [[ line['currency_code'] or '' ]] diff --git a/addons/account/report/general_ledger.py b/addons/account/report/general_ledger.py index 10baccc68a3..1e5343d8930 100644 --- a/addons/account/report/general_ledger.py +++ b/addons/account/report/general_ledger.py @@ -60,6 +60,7 @@ class general_ledger(rml_parse.rml_parse, common_report_header): 'sum_debit_account': self._sum_debit_account, 'sum_credit_account': self._sum_credit_account, 'sum_balance_account': self._sum_balance_account, + 'sum_currency_amount_account': self._sum_currency_amount_account, 'get_children_accounts': self.get_children_accounts, 'get_fiscalyear': self._get_fiscalyear, 'get_journal': self._get_journal, @@ -70,9 +71,24 @@ class general_ledger(rml_parse.rml_parse, common_report_header): 'get_sortby': self._get_sortby, 'get_start_date':self._get_start_date, 'get_end_date':self._get_end_date, + }) self.context = context + def _sum_currency_amount_account(self, account, form): + #FIXME: not working + self.cr.execute("SELECT sum(l.amount_currency) as tot_currency "\ + "FROM account_move_line l "\ + "WHERE l.account_id = %s AND %s"%(account.id, self.query)) + sum_currency = self.cr.fetchone()[0] or 0.0 + if form.get('initial_balance', False): + self.cr.execute("SELECT sum(l.amount_currency) as tot_currency "\ + "FROM account_move_line l "\ + "WHERE l.account_id = %s AND %s "%(account.id, form['initial_bal_query'])) + # Add initial balance to the result + sum_currency += self.cr.fetchone()[0] or 0.0 + return str(sum_currency) + def get_children_accounts(self, account, form): res = [] ids_acc = self.pool.get('account.account')._get_children_and_consol(self.cr, self.uid, account.id) diff --git a/addons/account/report/general_ledger.rml b/addons/account/report/general_ledger.rml index bae7e28e6b8..c8ab3ef80d0 100644 --- a/addons/account/report/general_ledger.rml +++ b/addons/account/report/general_ledger.rml @@ -321,7 +321,7 @@ [[formatLang(sum_debit_account(o, data['form'])) ]] [[formatLang(sum_credit_account(o, data['form'])) ]] [[formatLang(sum_balance_account(o, data['form'])) ]] - [[o.currency_id and formatLang(sum_currency_amount_account(a, data['form']))+o.currency_id.code or '' ]] + [[ o.currency_id and sum_currency_amount_account(o, data['form']) +o.currency_id.code or '' ]]