[ADD] Account: Common class for account type report where account print in reports

[IMP] change accoridingly with new class for account reports (display_account field)

bzr revid: mra@mra-laptop-20100728093332-opdxooergv1fqiyn
This commit is contained in:
Mustufa Rangwala 2010-07-28 15:03:32 +05:30
parent 93a8cd6c64
commit e994145041
8 changed files with 17 additions and 190 deletions

View File

@ -22,6 +22,7 @@
import account_report_common
import account_report_common_partner
import account_report_common_journal
import account_report_common_account
import account_automatic_reconcile
import account_move_line_reconcile_select
@ -47,7 +48,7 @@ import account_open_closed_fiscalyear
import account_compare_account_balance_report
import account_invoice_state
import account_chart
#TODO: remove this file no moe used
#TODO: remove this file no moe used
# also remove related view fiel
#import account_move_line_select

View File

@ -1,123 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
import time
from osv import fields, osv
from tools.translate import _
import tools
class account_general_ledger_report(osv.osv_memory):
_name = "account.general.ledger.report"
_description = "General Ledger Report"
_columns = {
'Account_list': fields.many2one('account.account', 'Chart account', required=True, domain = [('parent_id','=',False)]),
'company_id': fields.many2one('res.company', 'Company', required=True),
'state': fields.selection([('bydate','By Date'),
('byperiod','By Period'),
('all','By Date and Period'),
('none','No Filter')],"Date/Period Filter"),
'fiscalyear': fields.many2one('account.fiscalyear', 'Fiscal year', help='Keep empty for all open fiscal year'),
'periods': fields.many2many('account.period', 'ledger_period_rel', 'ledger_id', 'period_id', 'Periods', help='All periods if empty' ),
'sortbydate': fields.selection([('sort_date','Date'),
('sort_mvt','Movement')],"Sort by:"),
'display_account': fields.selection([('bal_all','All'), ('bal_movement','With movements'),
('bal_solde','With balance is not equal to 0'),
],'Display accounts', required=True),
'landscape': fields.boolean("Landscape Mode"),
'soldeinit': fields.boolean("Include initial balances"),
'amount_currency': fields.boolean("With Currency"),
'date_from': fields.date("Start date", required=True),
'date_to': fields.date("End date", 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]
_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' : False,
'landscape': True,
'amount_currency' : True,
}
def next_view(self, cr, uid, ids, context=None):
obj_model = self.pool.get('ir.model.data')
if context is None:
context = {}
data = self.read(cr, uid, ids, [])[0]
context.update({'Account_list': data['Account_list']})
model_data_ids = obj_model.search(cr,uid,[('model','=','ir.ui.view'),('name','=','account_general_ledger_report_view')])
resource_id = obj_model.read(cr, uid, model_data_ids, fields=['res_id'])[0]['res_id']
return {
'view_type': 'form',
'view_mode': 'form',
'res_model': 'account.general.ledger.report',
'views': [(resource_id,'form')],
'type': 'ir.actions.act_window',
'target': 'new',
'context': context
}
def check_report(self, cr, uid, ids, context=None):
if context is None:
context = {}
data={}
data['ids'] = context.get('active_ids',[])
data['form'] = self.read(cr, uid, ids, ['date_from', 'sortbydate', 'company_id', 'soldeinit', 'state', 'periods', 'date_to', 'amount_currency', 'display_account', 'landscape', 'fiscalyear'])[0]
data['form']['Account_list'] = context.get('Account_list',[])
if data['form']['Account_list']:
data['model'] = 'ir.ui.menu'
else:
data['model'] = 'account.account'
data['form']['context'] = context
if data['form']['landscape'] == True:
return {
'type': 'ir.actions.report.xml',
'report_name': 'account.general.ledger_landscape',
'datas': data,
'nodestroy':True,
}
else:
return {
'type': 'ir.actions.report.xml',
'report_name': 'account.general.ledger',
'datas': data,
'nodestroy':True,
}
account_general_ledger_report()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -19,25 +19,16 @@
#
##############################################################################
from osv import osv, fields
from osv import osv
class account_balance_report(osv.osv_memory):
_inherit = "account.common.report"
_inherit = "account.common.account.report"
_name = 'account.balance.report'
_description = 'Account Balance Report'
_columns = {
'display_account': fields.selection([('bal_all','All'), ('bal_movement','With movements'),
('bal_solde','With balance is not equal to 0'),
],'Display accounts', required=True),
}
_defaults = {
'display_account': 'bal_all'
}
def _print_report(self, cr, uid, ids, data, query_line, context=None):
data['form'].update(self.read(cr, uid, ids, ['display_account'])[0])
return {'type': 'ir.actions.report.xml', 'report_name': 'account.account.balance', 'datas': data, 'nodestroy':True}
data = self.pre_print_report(cr, uid, ids, data, query_line, context=context)
return {'type': 'ir.actions.report.xml', 'report_name': 'account.account.balance', 'datas': data}
account_balance_report()

View File

@ -20,34 +20,30 @@
##############################################################################
from osv import osv, fields
from tools.translate import _
class account_bs_report(osv.osv_memory):
"""
This wizard will provide the account balance sheet report by periods, between any two dates.
"""
_name = 'account.bs.report'
_inherit = "account.common.report"
_inherit = "account.common.account.report"
_description = 'Account Balance Sheet Report'
_columns = {
'display_account': fields.selection([('bal_all','All'), ('bal_movement','With movements'),
('bal_solde','With balance is not equal to 0'),
],'Display accounts', required=True),
'display_type': fields.boolean("Landscape Mode"),
'reserve_account_id': fields.many2one('account.account', 'Reserve & Surplus Account',required = True,
help='This Account is used for trasfering Profit/Loss(If It is Profit : Amount will be added, Loss : Amount will be duducted.), Which is calculated from Profilt & Loss Report', domain = [('type','=','payable')]),
}
_defaults={
'display_account': 'bal_all',
'display_type': True,
}
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, ['display_account', 'display_type', 'reserve_account_id'])[0])
data = self.pre_print_report(cr, uid, ids, data, query_line, context=context)
data['form'].update(self.read(cr, uid, ids, ['display_type', 'reserve_account_id'])[0])
if data['form']['display_type']:
return {
'type': 'ir.actions.report.xml',

View File

@ -27,7 +27,7 @@ class account_general_journal(osv.osv_memory):
def _print_report(self, cr, uid, ids, data, query_line, context=None):
data = self.pre_print_report(cr, uid, ids, data, query_line, context=context)
return {'type': 'ir.actions.report.xml', 'report_name': 'account.general.journal', 'datas': data, 'nodestroy':True, }
return {'type': 'ir.actions.report.xml', 'report_name': 'account.general.journal', 'datas': data}
account_general_journal()

View File

@ -22,21 +22,17 @@
from osv import fields, osv
class account_report_general_ledger(osv.osv_memory):
_inherit = "account.common.report"
_inherit = "account.common.account.report"
_name = "account.report.general.ledger"
_description = "General Ledger Report"
_columns = {
'display_account': fields.selection([('all','All'), ('movement','With movements'),
('balance','With balance is not equal to 0'),
],'Display accounts', required=True),
'landscape': fields.boolean("Landscape Mode"),
'initial_balance': fields.boolean("Include initial balances"),
'amount_currency': fields.boolean("With Currency"),
'sortby': fields.selection([('sort_date', 'Date'), ('sort_journal_partner', 'Journal & Partner')], 'Sort By', required=True),
}
_defaults = {
'display_account': 'all',
'landscape': True,
'amount_currency': True,
'sortby': 'sort_date',
@ -52,12 +48,13 @@ class account_report_general_ledger(osv.osv_memory):
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, ['display_account', 'landscape', 'initial_balance', 'amount_currency', 'sortby'])[0])
data = self.pre_print_report(cr, uid, ids, data, query_line, context=context)
data['form'].update(self.read(cr, uid, ids, ['landscape', 'initial_balance', 'amount_currency', 'sortby'])[0])
if not data['form']['fiscalyear_id']:# GTK client problem onchange does not consider in save record
data['form'].update({'initial_balance': False})
if data['form']['landscape']:
return { 'type': 'ir.actions.report.xml', 'report_name': 'account.general.ledger_landscape', 'datas': data, 'nodestroy':True }
return { 'type': 'ir.actions.report.xml', 'report_name': 'account.general.ledger', 'datas': data, 'nodestroy':True}
return { 'type': 'ir.actions.report.xml', 'report_name': 'account.general.ledger', 'datas': data}
account_report_general_ledger()

View File

@ -44,7 +44,6 @@ class account_partner_balance(osv.osv_memory):
'type': 'ir.actions.report.xml',
'report_name': 'account.partner.balance',
'datas': data,
'nodestroy': True,
}
account_partner_balance()

View File

@ -20,32 +20,27 @@
##############################################################################
from osv import osv, fields
from tools.translate import _
class account_pl_report(osv.osv_memory):
"""
This wizard will provide the account profit and loss report by periods, between any two dates.
"""
_inherit = "account.common.report"
_inherit = "account.common.account.report"
_name = "account.pl.report"
_description = "Account Profit And Loss Report"
_columns = {
# 'company_id': fields.many2one('res.company', 'Company', required=True),
'display_account': fields.selection([('bal_all','All'), ('bal_movement','With movements'),
('bal_solde','With balance is not equal to 0'),
],'Display accounts', required=True),
'display_type': fields.boolean("Landscape Mode"),
}
_defaults = {
'display_account': 'bal_all',
'display_type': True,
}
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, ['display_account', 'display_type'])[0])
data = self.pre_print_report(cr, uid, ids, data, query_line, context=context)
data['form'].update(self.read(cr, uid, ids, ['display_type'])[0])
if data['form']['display_type']:
return {
'type': 'ir.actions.report.xml',
@ -58,35 +53,6 @@ class account_pl_report(osv.osv_memory):
'report_name': 'pl.account',
'datas': data,
}
def _check_date(self, cr, uid, data, context=None):
if context is None:
context = {}
sql = """
SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where %s between f.date_start and f.date_stop """
cr.execute(sql,(data['form']['date_from'],))
res = cr.dictfetchall()
if res:
if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_to'] < res[0]['date_start']):
raise osv.except_osv(_('UserError'),_('Date to must be set between %s and %s') % (res[0]['date_start'], res[0]['date_stop']))
else:
if data['form']['display_type']:
return {
'type': 'ir.actions.report.xml',
'report_name': 'pl.account.horizontal',
'datas': data,
'nodestroy':True,
}
else:
return {
'type': 'ir.actions.report.xml',
'report_name': 'pl.account',
'datas': data,
'nodestroy':True,
}
else:
raise osv.except_osv(_('UserError'),_('Date not in a defined fiscal year'))
account_pl_report()