From 4f03e8ba6f7abc33a67444035332fe672914d81a Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Sat, 26 Jun 2010 15:15:31 +0530 Subject: [PATCH] [REM] revert the changes of revision number (3164.73.8 trunk_account_report_refactoring) bzr revid: mra@mra-laptop-20100626094531-x1d41gmmh2xkznye --- addons/account/__openerp__.py | 3 +- addons/account/report/general_ledger.py | 108 +++++++++++---- addons/account/report/general_ledger.rml | 94 ++++++------- .../report/general_ledger_landscape.rml | 28 ++-- addons/account/wizard/__init__.py | 5 +- .../account/wizard/account_common_report.py | 127 ------------------ .../account/wizard/account_common_report.xml | 116 ---------------- .../wizard/account_report_general_ledger.py | 58 -------- .../account_report_general_ledger_view.xml | 60 --------- 9 files changed, 150 insertions(+), 449 deletions(-) delete mode 100644 addons/account/wizard/account_common_report.py delete mode 100644 addons/account/wizard/account_common_report.xml delete mode 100644 addons/account/wizard/account_report_general_ledger.py delete mode 100644 addons/account/wizard/account_report_general_ledger_view.xml diff --git a/addons/account/__openerp__.py b/addons/account/__openerp__.py index ace32fe1b0c..04f55566d40 100644 --- a/addons/account/__openerp__.py +++ b/addons/account/__openerp__.py @@ -55,7 +55,6 @@ module named account_vouchers 'wizard/account_use_model_view.xml', 'account_view.xml', 'account_report.xml', - 'wizard/account_common_report.xml', 'wizard/account_invoice_refund_view.xml', 'wizard/account_period_close_view.xml', 'wizard/account_fiscalyear_close_state.xml', @@ -76,7 +75,7 @@ module named account_vouchers 'wizard/account_validate_move_view.xml', 'wizard/account_pay_invoice_view.xml', 'wizard/account_unreconcile_view.xml', - 'wizard/account_report_general_ledger_view.xml', + 'wizard/account_general_ledger_report_view.xml', 'wizard/account_invoice_state_view.xml', 'wizard/account_partner_balance_report_view.xml', 'wizard/account_balance_report_view.xml', diff --git a/addons/account/report/general_ledger.py b/addons/account/report/general_ledger.py index 195d6bc5746..32186c269f9 100644 --- a/addons/account/report/general_ledger.py +++ b/addons/account/report/general_ledger.py @@ -40,9 +40,12 @@ class general_ledger(rml_parse.rml_parse): new_ids = [] if (data['model'] == 'account.account'): new_ids = 'active_ids' in data['form']['context'] and data['form']['context']['active_ids'] or [] + #new_ids = ids else: - new_ids.append(data['form']['chart_account_id']) - objects = self.pool.get('account.account').browse(self.cr, self.uid, new_ids) + new_ids.append(data['form']['Account_list']) + + objects = self.pool.get('account.account').browse(self.cr, self.uid, new_ids) + super(general_ledger, self).set_context(objects, data, new_ids, report_type) def __init__(self, cr, uid, name, context): @@ -78,7 +81,7 @@ class general_ledger(rml_parse.rml_parse): res = self.cr.dictfetchall() borne_min = res[0]['start_date'] borne_max = res[0]['stop_date'] - if form['filter'] == 'filter_period': + if form['state'] == 'byperiod': ## This function will return the most aged date periods = form['periods'] #periods = form['periods'][0][2] @@ -96,10 +99,43 @@ class general_ledger(rml_parse.rml_parse): res = self.cr.dictfetchall() borne_min = res[0]['start_date'] borne_max = res[0]['stop_date'] - elif form['filter'] == 'filter_date': + elif form['state'] == 'bydate': borne_min = form['date_from'] borne_max = form['date_to'] - elif form['filter'] == 'filter_no': + elif form['state'] == 'all': + periods = form['periods'] + #periods = form['periods'][0][2] + if not periods: + sql = """ + SELECT MIN(p.date_start) AS start_date, + MAX(p.date_stop) AS stop_date + FROM account_period AS p + WHERE p.fiscalyear_id = %s + """ + sqlargs = (form['fiscalyear'],) + else: + sql = """ + SELECT MIN(p.date_start) AS start_date, + MAX(p.date_stop) AS stop_date + FROM account_period AS p + WHERE p.id IN %s + """ + sqlargs = (tuple(periods),) + self.cr.execute(sql, sqlargs) + res = self.cr.dictfetchall() + period_min = res[0]['start_date'] + period_max = res[0]['stop_date'] + date_min = form['date_from'] + date_max = form['date_to'] + if period_min%%s), ', ') AS counterpart - FROM (SELECT move_id FROM account_move_line l WHERE %s AND l.account_id = %%s GROUP BY move_id) m1 + FROM (SELECT move_id FROM account_move_line l WHERE %s AND l.account_id = %%s AND l.date<=%%s AND l.date>=%%s GROUP BY move_id) m1 """ % self.query - self.cr.execute(sql, (account.id, account.id)) + self.cr.execute(sql, (account.id, account.id, self.date_borne['max_date'], self.date_borne['min_date'])) counterpart_res = self.cr.dictfetchall() counterpart_accounts = {} for i in counterpart_res: @@ -191,10 +248,10 @@ class general_ledger(rml_parse.rml_parse): del counterpart_res # Then select all account_move_line of this account - if form['sortby'] == 'sort_journal_partner': - sql_sort='j.code, p.name' - else: + if form['sortbydate'] == 'sort_date': sql_sort='l.date' + else: + sql_sort='j.code' sql = """ SELECT l.id, l.date, j.code, l.amount_currency,l.ref, l.name, COALESCE(l.debit,0) AS debit, COALESCE(l.credit,0) AS credit, l.period_id, l.partner_id, m.name AS move_name, m.id AS move_id, @@ -207,9 +264,9 @@ class general_ledger(rml_parse.rml_parse): LEFT JOIN res_partner p on (l.partner_id=p.id) LEFT JOIN account_invoice i on (m.id =i.move_id) JOIN account_journal j on (l.journal_id=j.id) - WHERE %s AND l.account_id = %%s ORDER by %s + WHERE %s AND l.account_id = %%s AND l.date<=%%s AND l.date>=%%s ORDER by %s """ % (self.query, sql_sort) - self.cr.execute(sql, (account.id,)) + self.cr.execute(sql, (account.id, self.date_borne['max_date'], self.date_borne['min_date'])) res = self.cr.dictfetchall() account_sum = 0.0 account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') @@ -221,6 +278,8 @@ class general_ledger(rml_parse.rml_parse): l['ref'] = '%s: %s'%(inv_types[l['invoice_type']], l['invoice_number']) l['partner'] = l['partner_name'] or '' account_sum = l['debit'] - l ['credit'] + #c = time.strptime(l['date'],"%Y-%m-%d") + #l['date'] = time.strftime("%d-%m-%Y",c) l['progress'] = account_sum l['line_corresp'] = counterpart_accounts[l['move_id']] # Modification du amount Currency @@ -255,6 +314,9 @@ class general_ledger(rml_parse.rml_parse): sum_credit = self.cr.fetchone()[0] or 0.0 if form.get('soldeinit', False): sum_credit += account.init_credit + # + ## + return sum_credit def _sum_solde_account(self, account, form): diff --git a/addons/account/report/general_ledger.rml b/addons/account/report/general_ledger.rml index c66f0eba502..5358af913de 100644 --- a/addons/account/report/general_ledger.rml +++ b/addons/account/report/general_ledger.rml @@ -35,7 +35,7 @@ - + @@ -43,7 +43,7 @@ - + @@ -91,7 +91,7 @@ [[ repeatIn(objects, 'a') ]] - [[data['form']['amount_currency'] == False or removeParentNode('blockTable')]] + [[ data['form']['amount_currency'] == False or removeParentNode('blockTable') ]] Date Partner @@ -102,45 +102,46 @@ Crebit Balance - + +
+ [[ repeatIn(get_children_accounts(a,data['form']), 'o') ]] + [[ data['form']['amount_currency'] == False or removeParentNode('blockTable') ]] + + + + + [[ o.code or '']] [[ o.name or '']] + + [[formatLang(sum_debit_account(o, data['form'])) ]] + [[formatLang(sum_credit_account(o, data['form'])) ]] + [[formatLang(sum_solde_account(o, data['form'])) ]] + + + + + + + + + + + + + [[ repeatIn(lines(o, data['form']), 'line') ]] [[ formatLang(line['date'],date=True) ]] + [[ line['partner'] or '']] + [[ line['ref'] or '']] + [[ line['move'] or '']] + [[ line['name'] or '' ]] + [[ formatLang(line['debit']) ]] + [[ formatLang(line['credit']) ]] + [[ formatLang(line['progress']) ]] + + +
-
- [[ repeatIn(get_children_accounts(a,data['form']), 'o') ]] - [[data['form']['amount_currency'] == False or removeParentNode('blockTable')]] - - - - - [[ o.code or '']] [[ o.name or '']] - - [[formatLang(sum_debit_account(o, data['form'])) ]] - [[formatLang(sum_credit_account(o, data['form'])) ]] - [[formatLang(sum_solde_account(o, data['form'])) ]] - - - - - - - - - - - - - [[ repeatIn(lines(o, data['form']), 'line') ]] [[ formatLang(line['date'],date=True) ]] - [[ line['partner'] or '']] - [[ line['ref'] or '']] - [[ line['move'] or '']] - [[ line['name'] or '' ]] - [[ formatLang(line['debit']) ]] - [[ formatLang(line['credit']) ]] - [[ formatLang(line['progress']) ]] - - -
- - [[data['form']['amount_currency'] == True or removeParentNode('blockTable')]] + + + [[ data['form']['amount_currency'] == True or removeParentNode('blockTable') ]] Date Partner @@ -154,18 +155,18 @@
- [[repeatIn(get_children_accounts(a,data['form']), 'o')]] - [[data['form']['amount_currency'] == True or removeParentNode('blockTable')]] + [[ repeatIn(get_children_accounts(a,data['form']), 'o') ]] + [[ data['form']['amount_currency'] == True or removeParentNode('blockTable') ]] [[ o.code or '' ]] [[ o.name or '' ]] - [[formatLang(sum_debit_account(o, data['form'])) ]] + [[ formatLang(sum_debit_account(o, data['form'])) ]] [[formatLang(sum_credit_account(o, data['form'])) ]] [[formatLang(sum_solde_account(o, data['form'])) ]] - [[formatLang(sum_currency_amount_account(a, data['form'])) ]] + [[ formatLang(sum_currency_amount_account(a, data['form'])) ]] @@ -192,4 +193,7 @@
+ + + diff --git a/addons/account/report/general_ledger_landscape.rml b/addons/account/report/general_ledger_landscape.rml index 14e7d6b8c4c..e2ef020743e 100644 --- a/addons/account/report/general_ledger_landscape.rml +++ b/addons/account/report/general_ledger_landscape.rml @@ -83,8 +83,8 @@ [[ repeatIn(objects, 'a') ]] - - [[data['form']['amount_currency'] == True or removeParentNode('blockTable')]] + + [[ data['form']['amount_currency'] == True or removeParentNode('blockTable') ]] Date JNRL @@ -99,12 +99,12 @@ Currency - -
- + +
+ [[ repeatIn(get_children_accounts(a,data['form']), 'o') ]] - - [[data['form']['amount_currency'] == True or removeParentNode('blockTable')]] + + [[ data['form']['amount_currency'] == True or removeParentNode('blockTable') ]] @@ -143,9 +143,9 @@ [[ formatLang(line['amount_currency'] or 0.00)]] [[ line['currency_code'] ]] - +
- + [[ data['form']['amount_currency'] == False or removeParentNode('blockTable') ]] Date @@ -160,12 +160,12 @@ Balance - +
- + [[ repeatIn(get_children_accounts(a,data['form']), 'o') ]] - - [[data['form']['amount_currency'] == False or removeParentNode('blockTable')]] + + [[ data['form']['amount_currency'] == False or removeParentNode('blockTable') ]] @@ -201,7 +201,7 @@ [[ formatLang(line['progress']) ]] - +
diff --git a/addons/account/wizard/__init__.py b/addons/account/wizard/__init__.py index 1231c67463a..1dea8e8d4f3 100644 --- a/addons/account/wizard/__init__.py +++ b/addons/account/wizard/__init__.py @@ -19,8 +19,6 @@ # ############################################################################## -import account_common_report - import account_automatic_reconcile import account_move_line_reconcile_select import account_move_line_unreconcile_select @@ -34,8 +32,7 @@ import account_journal_select import account_move_bank_reconcile import account_subscription_generate import account_aged_trial_balance -#import account_general_ledger_report -import account_report_general_ledger +import account_general_ledger_report import account_third_party_ledger import account_partner_balance_report import account_balance_report diff --git a/addons/account/wizard/account_common_report.py b/addons/account/wizard/account_common_report.py deleted file mode 100644 index d87956b77a9..00000000000 --- a/addons/account/wizard/account_common_report.py +++ /dev/null @@ -1,127 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2010 Tiny SPRL (). -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## -import time - -from osv import fields, osv -from tools.translate import _ -import tools - -class account_common_report(osv.osv_memory): - _name = "account.common.report" - _description = "Common Report" - - _columns = { - 'chart_account_id': fields.many2one('account.account', 'Chart of account', required=True, domain = [('parent_id','=',False)]), - 'fiscalyear_id': fields.many2one('account.fiscalyear', 'Fiscal year', help='Keep empty for all open fiscal year'), - - 'filter': fields.selection([('filter_no','No filters'), ('filter_date','Date'), ('filter_period','Periods')],"Filter by:", required=True), - - 'period_from': fields.many2one('account.period', 'Start period'), - 'period_to': fields.many2one('account.period', 'End period'), - #not used. Do we really need it? 'period_ids': fields.many2many('account.period', 'ledger_period_rel', 'ledger_id', 'period_id', 'Periods'), - - 'journal_ids': fields.many2many('account.journal', 'account_common_journal_rel', 'account_id', 'journal_id', 'Journals', required=True), - - 'date_from': fields.date("Start date"), - 'date_to': fields.date("End date"), - - #'display_account': fields.selection([('bal_mouvement','With movements'), ('bal_all','All'), ('bal_solde','With balance is not equal to 0')],"Display accounts"), - #'landscape': fields.boolean("Landscape Mode"), - #'soldeinit': fields.boolean("Include initial balances"), - #'amount_currency': fields.boolean("With Currency"), - - #'filter': fields.boolean("Landscape Mode"), - #'state': fields.selection([('bydate','By Date'), ('byperiod','By Period'), ('all','By Date and Period'), ('none','No Filter')],"Date/Period Filter"), - #'company_id': fields.many2one('res.company', 'Company', required=True), - } - -# def _get_company(self, cr, uid, context=None): -# user_obj = self.pool.get('res.users') -# company_obj = self.pool.get('res.company') -# if context is None: -# context = {} -# user = user_obj.browse(cr, uid, uid, context=context) -# if user.company_id: -# return user.company_id.id -# else: -# return company_obj.search(cr, uid, [('parent_id', '=', False)])[0] - - def _get_account(self, cr, uid, context=None): - tmp = self.pool.get('account.account').search(cr, uid, [], limit=1 ) - if not tmp: - return False - return tmp[0] - - def _get_fiscalyear(self, cr, uid, context=None): - now = time.strftime('%Y-%m-%d') - tmp = self.pool.get('account.fiscalyear').search(cr, uid, [('date_start', '<', now), ('date_stop', '>', now)], limit=1 ) - if not tmp: - return False - return tmp[0] - - def _get_all_journal(self, cr, uid, context=None): - return self.pool.get('account.journal').search(cr, uid ,[]) - - _defaults = { -# 'state' : 'none', - 'date_from' : time.strftime('%Y-01-01'), - 'date_to' : time.strftime('%Y-%m-%d'), -# 'company_id' : _get_company, -# 'display_account' : 'bal_all', -# 'sortbydate' : 'sort_date', - 'fiscalyear_id' : _get_fiscalyear, -# 'landscape': True, -# 'amount_currency' : True, - 'journal_ids': _get_all_journal, - 'filter': 'filter_no', - 'chart_account_id': _get_account, - } - - def _build_context(self, cr, uid, ids, data, context = None): - result = {} - result['fiscalyear'] = data['form']['fiscalyear_id'] and data['form']['fiscalyear_id'] or False - if data['form']['filter'] == 'filter_date': - result['date_from'] = data['form']['date_from'] - result['date_to'] = data['form']['date_to'] - elif data['form']['filter'] == 'filter_period': - period_date_start = period_obj.read(cr, uid, data['form']['period_from'], ['date_start'])[0]['date_start'] - period_date_stop = period_obj.read(cr, uid, data['form']['period_to'], ['date_stop'])[0]['date_stop'] - cr.execute('SELECT id FROM account_period WHERE date_start >= %s AND date_stop <= %s', (period_date_start, period_date_stop)) - result['periods'] = lambda x: x[0], cr.fetchall() - return result - - def _print_report(self, cr, uid, ids, data, query_line, context): - raise (_('Error'), _('not implemented')) - - def check_report(self, cr, uid, ids, context=None): - obj_acc_move_line = self.pool.get('account.move.line') - data = {} - data['ids'] = context.get('active_ids',[]) - data['model'] = context.get('active_model', 'ir.ui.menu') - data['form'] = self.read(cr, uid, ids, ['date_from', 'date_to', 'fiscalyear_id', 'journal_ids', 'period_from', 'period_to', 'filter', 'chart_account_id'])[0] - used_context = self._build_context(cr, uid, ids, data, context) - query_line = obj_acc_move_line._query_get(cr, uid, - obj='l', context=used_context) - return self._print_report(cr, uid, ids, data, query_line, context) -account_common_report() - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/addons/account/wizard/account_common_report.xml b/addons/account/wizard/account_common_report.xml deleted file mode 100644 index d138c8ec2de..00000000000 --- a/addons/account/wizard/account_common_report.xml +++ /dev/null @@ -1,116 +0,0 @@ - - - - - Common Report - account.common.report - form - -
- - - - - - - - - - - - - - - - - - - - - - - -