2010-04-21 11:41:18 +00:00
|
|
|
# -*- 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 tools.translate import _
|
|
|
|
from osv import fields, osv
|
|
|
|
|
|
|
|
class account_partner_balance(osv.osv_memory):
|
|
|
|
"""
|
|
|
|
This wizard will provide the partner balance report by periods, between any two dates.
|
|
|
|
"""
|
2010-07-13 07:35:45 +00:00
|
|
|
_inherit = 'account.common.report'
|
2010-04-21 11:41:18 +00:00
|
|
|
_name = 'account.partner.balance'
|
2010-07-13 07:35:45 +00:00
|
|
|
_description = 'Print Account Partner Balance'
|
|
|
|
|
2010-04-21 11:41:18 +00:00
|
|
|
_columns = {
|
|
|
|
'result_selection': fields.selection([('customer','Receivable Accounts'),
|
|
|
|
('supplier','Payable Accounts'),
|
2010-06-29 13:48:46 +00:00
|
|
|
('Suppliers and Customers' ,'Receivable and Payable Accounts')],
|
2010-04-21 11:41:18 +00:00
|
|
|
'Partner', required=True),
|
|
|
|
'soldeinit': fields.boolean('Include initial balances'),
|
|
|
|
}
|
|
|
|
|
|
|
|
_defaults={
|
2010-06-29 13:48:46 +00:00
|
|
|
'result_selection' : 'Suppliers and Customers',
|
2010-04-29 06:35:55 +00:00
|
|
|
'soldeinit' : True,
|
2010-04-21 11:41:18 +00:00
|
|
|
}
|
|
|
|
|
2010-07-13 07:35:45 +00:00
|
|
|
def _check_date(self, cr, uid, data, context=None):
|
2010-04-21 11:41:18 +00:00
|
|
|
sql = """
|
|
|
|
SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where %s between f.date_start and f.date_stop """
|
2010-07-13 07:35:45 +00:00
|
|
|
cr.execute(sql, (data['form']['date_from'],))
|
2010-04-21 11:41:18 +00:00
|
|
|
res = cr.dictfetchall()
|
|
|
|
if res:
|
2010-07-13 07:35:45 +00:00
|
|
|
if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_to'] < res[0]['date_start']):
|
2010-04-21 11:41:18 +00:00
|
|
|
raise osv.except_osv(_('UserError'),_('Date to must be set between %s and %s') % (str(res[0]['date_start']), str(res[0]['date_stop'])))
|
|
|
|
else:
|
2010-07-13 07:35:45 +00:00
|
|
|
return True
|
2010-04-21 11:41:18 +00:00
|
|
|
else:
|
|
|
|
raise osv.except_osv(_('UserError'),_('Date not in a defined fiscal year'))
|
|
|
|
|
|
|
|
|
2010-07-13 07:35:45 +00:00
|
|
|
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])
|
|
|
|
if data['form']['filter'] == 'filter_date':
|
|
|
|
self._check_date(cr, uid, data, context)
|
|
|
|
data['form']['query_line'] = query_line
|
|
|
|
return {
|
|
|
|
'type': 'ir.actions.report.xml',
|
|
|
|
'report_name': 'account.partner.balance',
|
|
|
|
'datas': data,
|
|
|
|
'nodestroy': True,
|
|
|
|
}
|
|
|
|
|
|
|
|
account_partner_balance()
|
2010-04-21 11:41:18 +00:00
|
|
|
|
2010-07-13 07:35:45 +00:00
|
|
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|