[ADD] account: convert print central journal and print general journal to osv_memory wizard

bzr revid: psi@tinyerp.co.in-20100407132019-nk2ul2vfnfx0e5uu
This commit is contained in:
psi (Open ERP) 2010-04-07 18:50:19 +05:30
parent 7522de6840
commit 4d3ff7377e
11 changed files with 214 additions and 153 deletions

View File

@ -58,7 +58,8 @@ module named account_voucherss
'wizard/account_move_line_unreconcile_select_view.xml',
'wizard/account_vat_view.xml',
'wizard/account_print_journal_view.xml',
'wizard/account_general_journal_view.xml',
'wizard/account_central_journal_view.xml',
'wizard/account_subscription_generate_view.xml',
'project/wizard/project_account_analytic_line_view.xml',
'account_view.xml',

View File

@ -112,13 +112,13 @@
<menuitem icon="STOCK_PRINT" action="wizard_general_ledger" id="menu_general_ledger" parent="account.menu_generic_report" type="wizard"/>
<!-- <wizard id="wizard_print_journal" menu="False" model="account.journal.period" name="account.print.journal.report" string="Print Journal" />
<menuitem icon="STOCK_PRINT" action="wizard_print_journal" id="menu_print_journal" parent="account.menu_generic_report" type="wizard" />-->
<menuitem icon="STOCK_PRINT" action="wizard_print_journal" id="menu_print_journal" parent="account.menu_generic_report" type="wizard" />
<wizard id="wizard_central_journal" menu="False" model="account.journal.period" name="account.central.journal.report" string="Print Central Journal" />
<menuitem icon="STOCK_PRINT" action="wizard_central_journal" id="menu_central_journal" parent="account.menu_generic_report" type="wizard" />
<wizard id="wizard_general_journal" menu="False" model="account.journal.period" name="account.general.journal.report" string="Print General Journal" />
<menuitem icon="STOCK_PRINT" action="wizard_general_journal" id="menu_general_journal" parent="account.menu_generic_report" type="wizard" />
<menuitem icon="STOCK_PRINT" action="wizard_general_journal" id="menu_general_journal" parent="account.menu_generic_report" type="wizard" />-->
<wizard id="wizard_invoice_currency_change" model="account.invoice" name="account.invoice.currency_change" string="Change Currency" groups="base.group_user"/>
</data>

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/>.
#
##############################################################################
@ -59,8 +59,8 @@ class journal_print(report_sxw.rml_parse):
def _sum_credit(self, period_id, journal_id):
self.cr.execute('select sum(credit) from account_move_line where period_id=%s and journal_id=%s and state<>\'draft\'', (period_id, journal_id))
return self.cr.fetchone()[0] or 0.0
report_sxw.report_sxw('report.account.central.journal', 'account.journal.period', 'addons/account/report/central_journal.rml',parser=journal_print, header=False)
report_sxw.report_sxw('report.account.central.journal.wiz', 'account.journal.period', 'addons/account/report/wizard_central_journal.rml',parser=journal_print, header=False)
report_sxw.report_sxw('report.account.central.journal', 'account.journal.period', 'addons/account/report/central_journal.rml', parser=journal_print, header=False)
report_sxw.report_sxw('report.account.central.journal.wiz', 'account.journal.period', 'addons/account/report/wizard_central_journal.rml', parser=journal_print, header=False)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -122,8 +122,8 @@ class journal_print(report_sxw.rml_parse):
return 0.0
self.cr.execute('select sum(credit) from account_move_line where period_id =ANY(%s) and journal_id =ANY(%s) and state<>\'draft\'',(self.period_ids,self.journal_ids,))
return self.cr.fetchone()[0] or 0.0
report_sxw.report_sxw('report.account.general.journal', 'account.journal.period', 'addons/account/report/general_journal.rml',parser=journal_print)
report_sxw.report_sxw('report.account.general.journal.wiz', 'account.journal.period', 'addons/account/report/wizard_general_journal.rml',parser=journal_print, header=False)
report_sxw.report_sxw('report.account.general.journal', 'account.journal.period', 'addons/account/report/general_journal.rml', parser=journal_print)
report_sxw.report_sxw('report.account.general.journal.wiz', 'account.journal.period', 'addons/account/report/wizard_general_journal.rml', parser=journal_print, header=False)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -54,8 +54,8 @@ import wizard_state_open
import wizard_statement_from_invoice
import account_print_journal
import wizard_central_journal
import wizard_general_journal
import account_central_journal
import account_general_journal
import wizard_change_currency
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,61 @@
# -*- 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 osv, fields
class account_central_journal(osv.osv_memory):
_name = 'account.central.journal'
_description = 'Account Central Journal'
_columns = {
'journal_id': fields.many2many('account.journal', 'account_journal_rel', 'account_id', 'journal_id', 'Journals', required=True),
'period_id': fields.many2many('account.period', 'account_period_rel', 'account_id', 'period_id', 'Periods', required=True),
}
def check_data(self, cr, uid, ids, context={}):
obj_jperiod = self.pool.get('account.journal.period')
datas = {}
datas['ids'] = []
datas['model'] = 'account.journal.period'
datas['form'] = self.read(cr, uid, ids)[0]
period_id = datas['form']['period_id']
journal_id = datas['form']['journal_id']
if type(period_id)==type([]):
ids_final = []
for journal in journal_id:
for period in period_id:
ids_journal_period = obj_jperiod.search(cr,uid, [('journal_id','=',journal),('period_id','=',period)], context=context)
if ids_journal_period:
ids_final.append(ids_journal_period)
if not ids_final:
raise osv.except_osv(_('No Data Available'), _('No records found for your selection!'))
return {
'type': 'ir.actions.report.xml',
'report_name': 'account.central.journal',
'datas': datas,
}
account_central_journal()
#vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_account_central_journal" model="ir.ui.view">
<field name="name">Account central Journal</field>
<field name="model">account.central.journal</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Print Central Journal">
<group col="4" colspan="6">
<field name="journal_id"/>
<field name="period_id"/>
</group>
<separator colspan="4"/>
<group col="2" colspan="4">
<button special="cancel" string="Cancel" icon='gtk-cancel'/>
<button name="check_data" string="Print" colspan="1" type="object" icon="gtk-ok"/>
</group>
</form>
</field>
</record>
<record id="action_account_central_journal" model="ir.actions.act_window">
<field name="name">Account Central Journal</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">account.central.journal</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<menuitem
name="Print Central Journal"
parent="account.menu_generic_report"
action="action_account_central_journal"
id="menu_account_central_journal"
icon="STOCK_PRINT"/>
</data>
</openerp>

View File

@ -0,0 +1,59 @@
# -*- 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 osv, fields
class account_general_journal(osv.osv_memory):
_name = 'account.general.journal'
_description = 'Account General Journal'
_columns = {
'journal_id': fields.many2many('account.journal', 'account_journal_rel', 'account_id', 'journal_id', 'Journals', required=True),
'period_id': fields.many2many('account.period', 'account_period_rel', 'account_id', 'period_id', 'Periods', required=True),
}
def check_data(self, cr, uid, ids, context={}):
obj_jperiod = self.pool.get('account.journal.period')
datas = {}
datas['ids'] = []
datas['model'] = 'account.journal.period'
datas['form'] = self.read(cr, uid, ids)[0]
period_id = datas['form']['period_id']
journal_id = datas['form']['journal_id']
if type(period_id)==type([]):
ids_final = []
for journal in journal_id:
for period in period_id:
ids_journal_period = obj_jperiod.search(cr,uid, [('journal_id','=',journal),('period_id','=',period)], context=context)
if ids_journal_period:
ids_final.append(ids_journal_period)
if not ids_final:
raise osv.except_osv(_('No Data Available'), _('No records found for your selection!'))
return {
'type': 'ir.actions.report.xml',
'report_name': 'account.general.journal',
'datas': datas,
}
account_general_journal()
#vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_account_general_journal" model="ir.ui.view">
<field name="name">Account Genral Journal</field>
<field name="model">account.general.journal</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Print General Journal">
<group col="4" colspan="6">
<field name="journal_id"/>
<field name="period_id"/>
</group>
<separator colspan="4"/>
<group col="2" colspan="4">
<button special="cancel" string="Cancel" icon='gtk-cancel'/>
<button name="check_data" string="Print" colspan="1" type="object" icon="gtk-ok"/>
</group>
</form>
</field>
</record>
<record id="action_account_general_journal" model="ir.actions.act_window">
<field name="name">Account General Journal</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">account.general.journal</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<menuitem
name="Print General Journal"
parent="account.menu_generic_report"
action="action_account_general_journal"
id="menu_account_general_journal"
icon="STOCK_PRINT"/>
</data>
</openerp>

View File

@ -1,72 +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 pooler
from tools.translate import _
form = '''<?xml version="1.0"?>
<form string="Print Central Journal">
<field name="journal_id"/>
<field name="period_id"/>
</form>'''
fields = {
'journal_id': {'string': 'Journal', 'type': 'many2many', 'relation': 'account.journal', 'required': True},
'period_id': {'string': 'Period', 'type': 'many2many', 'relation': 'account.period', 'required': True},
}
def _check_data(self, cr, uid, data, *args):
period_id = data['form']['period_id'][0][2]
journal_id=data['form']['journal_id'][0][2]
if type(period_id)==type([]):
ids_final = []
for journal in journal_id:
for period in period_id:
ids_journal_period = pooler.get_pool(cr.dbname).get('account.journal.period').search(cr,uid, [('journal_id','=',journal),('period_id','=',period)])
if ids_journal_period:
ids_final.append(ids_journal_period)
if not ids_final:
raise wizard.except_wizard(_('No Data Available'), _('No records found for your selection!'))
return data['form']
class wizard_print_journal(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch': form, 'fields': fields, 'state': (('end', 'Cancel', 'gtk-cancel'), ('print', 'Print', 'gtk-ok'))},
},
'print': {
'actions': [_check_data],
'result': {'type':'print', 'report':'account.central.journal.wiz', 'state':'end'},
},
}
wizard_print_journal('account.central.journal.report')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,70 +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 pooler
from tools.translate import _
form = '''<?xml version="1.0"?>
<form string="Print General Journal">
<field name="journal_id"/>
<field name="period_id"/>
</form>'''
fields = {
'journal_id': {'string': 'Journal', 'type': 'many2many', 'relation': 'account.journal', 'required': True},
'period_id': {'string': 'Period', 'type': 'many2many', 'relation': 'account.period', 'required': True},
}
def _check_data(self, cr, uid, data, *args):
period_id = data['form']['period_id'][0][2]
journal_id=data['form']['journal_id'][0][2]
if type(period_id)==type([]):
ids_final = []
for journal in journal_id:
for period in period_id:
ids_journal_period = pooler.get_pool(cr.dbname).get('account.journal.period').search(cr,uid, [('journal_id','=',journal),('period_id','=',period)])
if ids_journal_period:
ids_final.append(ids_journal_period)
if not ids_final:
raise wizard.except_wizard(_('No Data Available'), _('No records found for your selection!'))
return data['form']
class wizard_print_journal(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch': form, 'fields': fields, 'state': (('end', 'Cancel', 'gtk-cancel'), ('print', 'Print', 'gtk-ok'))},
},
'print': {
'actions': [_check_data],
'result': {'type':'print', 'report':'account.general.journal.wiz', 'state':'end'},
},
}
wizard_print_journal('account.general.journal.report')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: