From a39f8a5736f6f8a82f8deed7cca15ca74ef540ff Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Tue, 13 Jul 2010 15:11:57 +0530 Subject: [PATCH] [IMP] Account: Partner balance: improve with new class added common partner report bzr revid: mra@mra-laptop-20100713094157-f1s520efs0hirmf1 --- addons/account/wizard/__init__.py | 1 + .../wizard/account_common_journal_report.py | 2 +- .../wizard/account_common_partner_report.py | 47 +++++++++++++++++++ .../wizard/account_partner_balance_report.py | 16 ++----- 4 files changed, 54 insertions(+), 12 deletions(-) create mode 100644 addons/account/wizard/account_common_partner_report.py diff --git a/addons/account/wizard/__init__.py b/addons/account/wizard/__init__.py index 8437620063d..b3ad68bce57 100644 --- a/addons/account/wizard/__init__.py +++ b/addons/account/wizard/__init__.py @@ -20,6 +20,7 @@ ############################################################################## import account_common_report +import account_common_partner_report import account_automatic_reconcile import account_move_line_reconcile_select diff --git a/addons/account/wizard/account_common_journal_report.py b/addons/account/wizard/account_common_journal_report.py index b08786cc4e3..1564c8ab9d8 100644 --- a/addons/account/wizard/account_common_journal_report.py +++ b/addons/account/wizard/account_common_journal_report.py @@ -23,7 +23,7 @@ from tools.translate import _ class account_common_journal_report(osv.osv_memory): _name = 'account.common.journal.report' - _description = 'Account Commont Journal Report' + _description = 'Account Common Journal Report' _inherit = "account.common.report" def _build_context(self, cr, uid, ids, data, context=None): diff --git a/addons/account/wizard/account_common_partner_report.py b/addons/account/wizard/account_common_partner_report.py new file mode 100644 index 00000000000..308a7e92f3c --- /dev/null +++ b/addons/account/wizard/account_common_partner_report.py @@ -0,0 +1,47 @@ +# -*- 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 . +# +############################################################################## +from osv import osv, fields +from tools.translate import _ + +class account_common_partner_report(osv.osv_memory): + _name = 'account.common.partner.report' + _description = 'Account Common Partner Report' + _inherit = "account.common.report" + + _columns = { + 'result_selection': fields.selection([('customer','Receivable Accounts'), + ('supplier','Payable Accounts'), + ('Suppliers and Customers' ,'Receivable and Payable Accounts')], + 'Partner', required=True), + } + _defaults = { + 'result_selection' : 'Suppliers and Customers', + } + + def pre_print_report(self, cr, uid, ids, data, query_line, context=None): + data['form'].update(self.read(cr, uid, ids, ['result_selection'])[0]) + data['form']['active_ids'] = data['form']['chart_account_id'] # Check me + data['form']['query_line'] = query_line + return data + +account_common_partner_report() + +#vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/wizard/account_partner_balance_report.py b/addons/account/wizard/account_partner_balance_report.py index af82f43994b..09b79801111 100644 --- a/addons/account/wizard/account_partner_balance_report.py +++ b/addons/account/wizard/account_partner_balance_report.py @@ -27,22 +27,16 @@ class account_partner_balance(osv.osv_memory): """ This wizard will provide the partner balance report by periods, between any two dates. """ - _inherit = 'account.common.report' + _inherit = 'account.common.partner.report' _name = 'account.partner.balance' _description = 'Print Account Partner Balance' _columns = { - 'result_selection': fields.selection([('customer','Receivable Accounts'), - ('supplier','Payable Accounts'), - ('Suppliers and Customers' ,'Receivable and Payable Accounts')], - 'Partner', required=True), 'soldeinit': fields.boolean('Include initial balances'), - } - + } _defaults={ - 'result_selection' : 'Suppliers and Customers', 'soldeinit' : True, - } + } def _check_date(self, cr, uid, data, context=None): sql = """ @@ -57,11 +51,11 @@ class account_partner_balance(osv.osv_memory): else: raise osv.except_osv(_('UserError'),_('Date not in a defined fiscal year')) - def _print_report(self, cr, uid, ids, data, query_line, context=None): if context is None: context = {} - data['form'].update(self.read(cr, uid, ids, ['company_id', 'result_selection', 'soldeinit'])[0]) + data = self.pre_print_report(cr, uid, ids, data, query_line, context=context) + data['form'].update(self.read(cr, uid, ids, ['soldeinit'])[0]) if data['form']['filter'] == 'filter_date': self._check_date(cr, uid, data, context) data['form']['query_line'] = query_line