X-Git-Url: http://git.inspyration.org/?a=blobdiff_plain;f=addons%2Faccount%2Freport%2Faccount_central_journal.py;h=d3113b6313396145d83d77c4cb8dcf1428c76a57;hb=4c8a58015ae2edfc87e5e65dce1b651a21e26f1d;hp=36af31da363d8c3d00ff4150d6af86bc4d2706b7;hpb=d32fc299f909c07135b03f480f63613c9826b53a;p=odoo%2Fodoo.git diff --git a/addons/account/report/account_central_journal.py b/addons/account/report/account_central_journal.py index 36af31d..d3113b6 100644 --- a/addons/account/report/account_central_journal.py +++ b/addons/account/report/account_central_journal.py @@ -20,7 +20,6 @@ ############################################################################## import time - from report import report_sxw from common_report_header import common_report_header # @@ -48,12 +47,14 @@ class journal_print(report_sxw.rml_parse, common_report_header): 'get_start_date':self._get_start_date, 'get_end_date':self._get_end_date, 'display_currency':self._display_currency, + 'get_target_move': self._get_target_move, }) def set_context(self, objects, data, ids, report_type=None): obj_move = self.pool.get('account.move.line') new_ids = ids self.query_get_clause = '' + self.target_move = data['form'].get('target_move', 'all') if (data['model'] == 'ir.ui.menu'): new_ids = 'active_ids' in data['form'] and data['form']['active_ids'] or [] self.query_get_clause = 'AND ' @@ -66,11 +67,19 @@ class journal_print(report_sxw.rml_parse, common_report_header): return super(journal_print, self).set_context(objects, data, ids, report_type=report_type) def lines(self, period_id, journal_id): - self.cr.execute('SELECT a.currency_id ,a.code, a.name, c.code AS currency_code,l.currency_id ,l.amount_currency ,SUM(debit) AS debit, SUM(credit) AS credit from account_move_line l LEFT JOIN account_account a ON (l.account_id=a.id) LEFT JOIN res_currency c on (l.currency_id=c.id)WHERE l.period_id=%s AND l.journal_id=%s '+self.query_get_clause+' GROUP BY a.id, a.code, a.name,l.amount_currency,c.code , a.currency_id,l.currency_id', (period_id, journal_id)) + move_state = ['draft','posted'] + if self.target_move == 'posted': + move_state = ['posted'] + + self.cr.execute('SELECT a.currency_id, a.code, a.name, c.symbol AS currency_code, l.currency_id, l.amount_currency, SUM(debit) AS debit, SUM(credit) AS credit \ + from account_move_line l \ + LEFT JOIN account_move am ON (l.move_id=am.id) \ + LEFT JOIN account_account a ON (l.account_id=a.id) \ + LEFT JOIN res_currency c on (l.currency_id=c.id) WHERE am.state IN %s AND l.period_id=%s AND l.journal_id=%s '+self.query_get_clause+' GROUP BY a.id, a.code, a.name,l.amount_currency,c.symbol, a.currency_id,l.currency_id', (tuple(move_state), period_id, journal_id)) return self.cr.dictfetchall() def _set_get_account_currency_code(self, account_id): - self.cr.execute("SELECT c.code as code "\ + self.cr.execute("SELECT c.symbol 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() @@ -82,12 +91,12 @@ class journal_print(report_sxw.rml_parse, common_report_header): def _get_account(self, data): if data['model'] == 'account.journal.period': return self.pool.get('account.journal.period').browse(self.cr, self.uid, data['id']).company_id.name - return super(journal_print ,self)._get_account(data) + return super(journal_print,self)._get_account(data) def _get_fiscalyear(self, data): if data['model'] == 'account.journal.period': return self.pool.get('account.journal.period').browse(self.cr, self.uid, data['id']).fiscalyear_id.name - return super(journal_print ,self)._get_fiscalyear(data) + return super(journal_print,self)._get_fiscalyear(data) def _display_currency(self, data): if data['model'] == 'account.journal.period':