common view

bzr revid: al@openerp.com-20100614084824-o1qyp0sssbiznc6b
This commit is contained in:
Antony Lesuisse
2010-06-14 10:48:24 +02:00
parent 762cfbf1cc
commit d380424ad8
3 changed files with 173 additions and 1 deletions
@@ -8,7 +8,6 @@
<field name="arch" type="xml">
<form string="Select Date-Period">
<group colspan="4" col="6">
<field name="account_id" colspan="2" widget='selection'/>
<field name="fiscalyear_id"/>
@@ -0,0 +1,71 @@
# -*- 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_report_general_ledger(osv.osv_memory):
_inherit = "account.common.report"
_name = "account.report.general.ledger"
_description = "General Ledger Report"
_columns = {
'display_account': fields.selection([('bal_mouvement','With movements'), ('bal_all','All'), ('bal_solde','With balance is not equal to 0')],"Display accounts"),
'landscape': fields.boolean("Landscape Mode"),
'soldeinit': fields.boolean("Include initial balances"),
'amount_currency': fields.boolean("With Currency"),
#'state': fields.selection([('bydate','By Date'), ('byperiod','By Period'), ('all','By Date and Period'), ('none','No Filter')],"Date/Period Filter"),
}
_defaults = {
'display_account' : 'bal_all',
'landscape': True,
'amount_currency' : True,
}
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, )[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']['state'] == 'bydate':
return self._check_date(cr, uid, data, context)
elif data['form']['state'] == 'byperiod':
if not data['form']['periods']:
raise osv.except_osv(_('Data Insufficient !'),_('Please select periods.'))
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:
@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="account_general_ledger_report_view" model="ir.ui.view">
<field name="name">General Ledger</field>
<field name="model">account.general.ledger.report</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Select Date-Period">
<field name="company_id" colspan="4" groups="base.group_multi_company"/>
<newline/>
<field name="fiscalyear"/>
<label colspan="2" string="(Keep empty for all open fiscal years)" align="0.0"/>
<newline/>
<field name="display_account" required="True"/>
<field name="sortbydate" required="True"/>
<field name="soldeinit" invisible="1"/>
<field name="landscape"/>
<field name="amount_currency"/>
<newline/>
<separator string="Filters" colspan="4"/>
<field name="state" required="True"/>
<newline/>
<group attrs="{'invisible':[('state','=','none')]}" colspan="4">
<group attrs="{'invisible':[('state','=','byperiod')]}" colspan="4">
<separator string="Date Filter" colspan="4"/>
<field name="date_from"/>
<field name="date_to"/>
</group>
<group attrs="{'invisible':[('state','=','bydate')]}" colspan="4">
<separator string="Filter on Periods" colspan="4"/>
<field name="periods" colspan="4" nolabel="1"/>
</group>
</group>
<newline/>
<group colspan="4" col="6">
<separator colspan="4"/>
<button special="cancel" string="Cancel" icon="gtk-cancel"/>
<button name="check_report" string="Print" type="object" icon="gtk-print"/>
</group>
</form>
</field>
</record>
<record id="action_account_general_ledger_report" model="ir.actions.act_window">
<field name="name">General Ledger</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">account.general.ledger.report</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="account_general_ledger_report_view"/>
<field name="target">new</field>
</record>
<record model="ir.values" id="account_general_ledger_report_values">
<field name="model_id" ref="account.model_account_account" />
<field name="object" eval="1" />
<field name="name">Account General Ledger</field>
<field name="key2">client_print_multi</field>
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_account_general_ledger_report'))" />
<field name="key">action</field>
<field name="model">account.account</field>
</record>
<record id="account_general_ledger_report_view1" model="ir.ui.view">
<field name="name">General Ledger</field>
<field name="model">account.general.ledger.report</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Select Chart">
<field name="Account_list"/>
<separator colspan="4"/>
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button name="next_view" string="Next" type="object" icon="gtk-go-forward" default_focus="1"/>
</form>
</field>
</record>
<record id="action_account_general_ledger_menu" model="ir.actions.act_window">
<field name="name">Select Chart</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">account.general.ledger.report</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="account_general_ledger_report_view1"/>
<field name="target">new</field>
</record>
<menuitem
icon="STOCK_PRINT"
name="General Ledger"
parent="account.menu_generic_report"
action="action_account_general_ledger_menu"
id="menu_general_ledger"
/>
</data>
</openerp>