[ADD,MOD] account_reporting : wizard converted to osv memory wizard

bzr revid: vir@tinyerp.com-20100430114819-o670cxzyh0ii0z0h
This commit is contained in:
Vir (Open ERP) 2010-04-30 17:18:19 +05:30
parent e4a3054a53
commit 7162874a62
7 changed files with 129 additions and 120 deletions

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
@ -15,7 +15,7 @@
# 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/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
@ -33,7 +33,8 @@
'security/ir.model.access.csv',
'account_view.xml',
'account_report.xml',
'account_data.xml'
'account_data.xml',
'wizard/account_reporting_balance_report_view.xml',
],
'demo_xml': [],
'installable': True,

View File

@ -7,12 +7,12 @@
name="account.report.bs"
rml="addons/account_report_bs/report/account_report_bs.rml"
auto="False"/>-->
<wizard
string="Account balance"
model="account.report.bs"
name="account.account.balancesheet.report"
keyword="client_print_multi"
id="wizard_balance_report"/>
<!-- <wizard-->
<!-- string="Account balance"-->
<!-- model="account.report.bs"-->
<!-- name="account.account.balancesheet.report"-->
<!-- keyword="client_print_multi"-->
<!-- id="wizard_balance_report"/>-->
</data>
</openerp>

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
@ -15,7 +15,7 @@
# 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/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
@ -61,7 +61,7 @@ class account_report_bs(report_sxw.rml_parse):
if object:
ids = [object.id]
elif not ids:
ids = self.ids
ids = self.ids
if not ids:
return []
if not done:
@ -69,7 +69,7 @@ class account_report_bs(report_sxw.rml_parse):
result = []
ctx = self.context.copy()
ctx['fiscalyear'] = form['fiscalyear']
ctx['periods'] = form['periods'][0][2]
ctx['periods'] = form['periods']
report_objs = self.pool.get('account.report.bs').browse(self.cr, self.uid, ids)
title_name = False
if level==1:
@ -130,7 +130,7 @@ class account_report_bs(report_sxw.rml_parse):
ids2 = [(x.code,x.id) for x in report_obj.child_id]
ids2.sort()
result += self.lines(form,[x[1] for x in ids2], done, level+1,object=False)
return result
# def check_child_id(self,account_id,level,ctx,report_type):
@ -151,13 +151,13 @@ class account_report_bs(report_sxw.rml_parse):
# for child_id in acc_child_id :
# result += self.check_child_id(child_id,level+1,ctx,report_type)
# return result
# def _sum_credit(self):
#
#
#
# def _sum_credit(self):
# return self.sum_credit
#
# def _sum_debit(self):
# def _sum_debit(self):
# return self.sum_debit
report_sxw.report_sxw('report.account.report.bs', 'account.report.bs', 'addons/account_reporting/report/account_report_bs.rml', parser=account_report_bs)

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
@ -15,10 +15,10 @@
# 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/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard_account_balance_report
import account_reporting_balance_report
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,62 @@
# -*- 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/>.
#
##############################################################################
from osv import fields, osv
from tools.translate import _
class account_reporting_balance_report(osv.osv_memory):
def _get_fiscalyear(self, cr, uid, context=None):
"""Return default Fiscalyear value"""
fiscalyear_obj = self.pool.get('account.fiscalyear')
fiscalyear = fiscalyear_obj.find(cr, uid)
return fiscalyear
_name = 'account.reporting.balance.report'
_description = 'Account balance report'
_columns = {
'fiscalyear': fields.many2one('account.fiscalyear', 'Fiscal year', required=True),
'periods': fields.many2many('account.period', 'acc_reporting_relation', 'acc_id','period_id', 'Periods', help='All periods if empty'),
}
_defaults = {
'fiscalyear' : _get_fiscalyear,
}
def check_report(self, cr, uid, ids, context=None):
datas = {}
if context is None:
context = {}
data = self.read(cr, uid, ids)[0]
datas = {
'ids': context.get('active_ids',[]),
'model': 'account.report.bs',
'form': data
}
datas['form']['report_type'] = 'only_obj'
return {
'type': 'ir.actions.report.xml',
'report_name': 'account.report.bs',
'datas': datas,
}
account_reporting_balance_report()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="account_reporting_balance_report_view" model="ir.ui.view">
<field name="name">account.reporting.balance.report.form</field>
<field name="model">account.reporting.balance.report</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Select Dates Period">
<field name="fiscalyear"/>
<newline/>
<field name="periods"/>
<group colspan="4" col="6">
<label string ="" colspan="2"/>
<button special="cancel" string="Cancel" icon="gtk-cancel"/>
<button name="check_report" string="Print" type="object" icon="gtk-print" default_focus="1"/>
</group>
</form>
</field>
</record>
<record id="action_account_reporting_balance_report" model="ir.actions.act_window">
<field name="name">Account Balance</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">account.reporting.balance.report</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="account_reporting_balance_report_view"/>
<field name="target">new</field>
</record>
<record model="ir.values" id="account_reporting_balance_report_values">
<field name="model_id" ref="account_reporting.model_account_report_bs" />
<field name="object" eval="1" />
<field name="name">Account Balance</field>
<field name="key2">client_print_multi</field>
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_account_reporting_balance_report'))" />
<field name="key">action</field>
<field name="model">account.report.bs</field>
</record>
</data>
</openerp>

View File

@ -1,98 +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 wizard
import ir
import pooler
import time
import netsvc
from osv import fields, osv
import mx.DateTime
from mx.DateTime import RelativeDateTime
from tools import config
dates_form = '''<?xml version="1.0"?>
<form string="Customize Report">
<field name="fiscalyear" colspan="4"/>
<field name="periods" colspan="4"/>
</form>'''
# <field name="report_type" colspan="4"/>
dates_fields = {
'fiscalyear': {'string': 'Fiscal year', 'type': 'many2one', 'relation': 'account.fiscalyear', 'required': True},
'periods': {'string': 'Periods', 'type': 'many2many', 'relation': 'account.period', 'help': 'All periods if empty'},
# 'report_type': {'string': 'Report Type','type': 'selection','selection': [('only_obj', 'Report Objects Only'),('with_account', 'Report Objects With Accounts'),('acc_with_child', 'Report Objects With Accounts and child of Accounts'),],'required': True},
}
back_form='''<?xml version="1.0"?>
<form string="Notification">
<separator string="You might have done following mistakes.Please correct them and try again." colspan="4"/>
<separator string="1. You have selected more than 3 years in any case." colspan="4"/>
<separator string="2. You have not selected 'Percentage' option,but you have selected more than 2 years." colspan="4"/>
<label string="You can select maximum 3 years.Please check again." colspan="4"/>
</form>'''
back_fields={
}
zero_form='''<?xml version="1.0"?>
<form string="Notification">
<label string="You have to select at least 1 Fiscal Year. Try again."/>
</form>'''
zero_fields={
}
periods_form='''<?xml version="1.0"?>
<form string="Set Periods">
<separator string="Select Period(s) (All periods if empty)" colspan="4"/>
<field name="periods" colspan="4" nolabel="1"/>
</form>'''
periods_fields={
'periods': {'string': 'Periods', 'type': 'many2many', 'relation': 'account.period', 'help': 'All periods if empty'}
}
class wizard_report(wizard.interface):
def _get_defaults(self, cr, uid, data, context):
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
data['form']['report_type'] = 'only_obj'
return data['form']
states = {
'init': {
'actions': [_get_defaults],
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('report','Print BalanceSheet')]}
},
'report': {
'actions': [],
'result': {'type':'print', 'report':'account.report.bs', 'state':'end'}
}
}
wizard_report('account.account.balancesheet.report')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: