[IMP] Se une en un solo Wizard todos los reportes
parent
827d6dd95d
commit
67a6556955
|
@ -37,8 +37,8 @@
|
|||
"demo_xml" : [],
|
||||
"update_xml" : [
|
||||
"security/security.xml",
|
||||
"wizard/wizard_report_report.xml",
|
||||
"wizard/account_report_wizard.xml",
|
||||
"view/report.xml",
|
||||
"view/wizard.xml",
|
||||
"view/account_view.xml",
|
||||
"view/company_view.xml",
|
||||
],
|
||||
|
|
|
@ -2,32 +2,34 @@
|
|||
<openerp>
|
||||
<data >
|
||||
<report
|
||||
id="account_balance_full"
|
||||
string="General account balance"
|
||||
model="account.account"
|
||||
name="account.account.balance.gene"
|
||||
rml="account_financial_report/report/balance_full.rml"
|
||||
header="False"
|
||||
auto="False"
|
||||
menu="False"/>
|
||||
<report
|
||||
id="account_balance_full_4_cols"
|
||||
string="General account balance Four Columns"
|
||||
model="account.account"
|
||||
name="account.account.balance.gene.4"
|
||||
id="wizard_report_reporte_4_col"
|
||||
menu="True"
|
||||
model="wizard.report"
|
||||
name="wizard.report.reporte"
|
||||
rml="account_financial_report/report/balance_full_4_cols.rml"
|
||||
string="Balance de Comprobacion Wizard 4 Columnas"
|
||||
header="False"
|
||||
auto="False"
|
||||
menu="False"/>
|
||||
/>
|
||||
<report
|
||||
id="account_balance_full_2_cols"
|
||||
string="General account balance Two Columns"
|
||||
model="account.account"
|
||||
auto="False"
|
||||
id="wizard_report_reporte_2_col"
|
||||
menu="True"
|
||||
model="wizard.report.account.balance.gene.2"
|
||||
name="account.account.balance.gene.2"
|
||||
rml="account_financial_report/report/balance_full_2_cols.rml"
|
||||
string="Balance de Comprobacion Wizard 2 Columnas"
|
||||
header="False"
|
||||
/>
|
||||
<report
|
||||
auto="False"
|
||||
menu="False"/>
|
||||
id="wizard_report_reporte"
|
||||
menu="True"
|
||||
model="wizard.report.account.balance.gene"
|
||||
name="account.account.balance.gene"
|
||||
rml="account_financial_report/report/balance_full.rml"
|
||||
string="Balance de Comprobacion Wizard"
|
||||
header="False"
|
||||
/>
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
|
|
|
@ -384,21 +384,20 @@ class account_balance(report_sxw.rml_parse):
|
|||
result_acc.append(res2)
|
||||
return result_acc
|
||||
|
||||
|
||||
report_sxw.report_sxw('report.wizard.report.reporte',
|
||||
report_sxw.report_sxw('report.afr.1cols',
|
||||
'wizard.report',
|
||||
'account_financial_report/report/balance_full_4_cols.rml',
|
||||
'account_financial_report/report/balance_full.rml',
|
||||
parser=account_balance,
|
||||
header=False)
|
||||
|
||||
report_sxw.report_sxw('report.account.account.balance.gene.2',
|
||||
'wizard.report.account.balance.gene.2',
|
||||
report_sxw.report_sxw('report.afr.2cols',
|
||||
'wizard.report',
|
||||
'account_financial_report/report/balance_full_2_cols.rml',
|
||||
parser=account_balance,
|
||||
header=False)
|
||||
|
||||
report_sxw.report_sxw('report.account.account.balance.gene',
|
||||
'wizard.report.account.balance.gene',
|
||||
'account_financial_report/report/balance_full.rml',
|
||||
report_sxw.report_sxw('report.afr.4cols',
|
||||
'wizard.report',
|
||||
'account_financial_report/report/balance_full_4_cols.rml',
|
||||
parser=account_balance,
|
||||
header=False)
|
||||
|
|
|
@ -1,36 +1,38 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<report
|
||||
auto="False"
|
||||
id="wizard_report_reporte_4_col"
|
||||
id="1_col_report"
|
||||
menu="True"
|
||||
model="wizard.report"
|
||||
name="wizard.report.reporte"
|
||||
rml="account_financial_report/report/balance_full_4_cols.rml"
|
||||
string="Balance de Comprobacion Wizard 4 Columnas"
|
||||
header="False"
|
||||
/>
|
||||
<report
|
||||
auto="False"
|
||||
id="wizard_report_reporte_2_col"
|
||||
menu="True"
|
||||
model="wizard.report.account.balance.gene.2"
|
||||
name="account.account.balance.gene.2"
|
||||
rml="account_financial_report/report/balance_full_2_cols.rml"
|
||||
string="Balance de Comprobacion Wizard 2 Columnas"
|
||||
header="False"
|
||||
/>
|
||||
<report
|
||||
auto="False"
|
||||
id="wizard_report_reporte"
|
||||
menu="True"
|
||||
model="wizard.report.account.balance.gene"
|
||||
name="account.account.balance.gene"
|
||||
name="afr.1cols"
|
||||
rml="account_financial_report/report/balance_full.rml"
|
||||
string="Balance de Comprobacion Wizard"
|
||||
header="False"
|
||||
/>
|
||||
|
||||
<report
|
||||
auto="False"
|
||||
id="2_col_report"
|
||||
menu="True"
|
||||
model="wizard.report"
|
||||
name="afr.2cols"
|
||||
rml="account_financial_report/report/balance_full_2_cols.rml"
|
||||
string="Balance de Comprobacion Wizard 2 Columnas"
|
||||
header="False"
|
||||
/>
|
||||
|
||||
<report
|
||||
auto="False"
|
||||
id="4_col_report"
|
||||
menu="True"
|
||||
model="wizard.report"
|
||||
name="afr.4cols"
|
||||
rml="account_financial_report/report/balance_full_4_cols.rml"
|
||||
string="Balance de Comprobacion Wizard 4 Columnas"
|
||||
header="False"
|
||||
/>
|
||||
</data>
|
||||
</openerp>
|
|
@ -0,0 +1,94 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="wizard_report_view" model="ir.ui.view">
|
||||
<field name="name">Wizard Report Balance Four Columns</field>
|
||||
<field name="model">wizard.report</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="General Account Balance (Multireports)">
|
||||
<group colspan="4">
|
||||
<group colspan="2">
|
||||
<separator string="Company Info" colspan="4"/>
|
||||
<field name="company_id" colspan="4"/>
|
||||
<field name="currency_id" domain="[('company_id','=',company_id)]" colspan="4"/>
|
||||
</group>
|
||||
|
||||
<group colspan="2">
|
||||
<separator string="Report Info" colspan="4"/>
|
||||
<field name="inf_type" colspan="4"/>
|
||||
<field name="columns" colspan="4"/>
|
||||
</group>
|
||||
</group>
|
||||
<newline/>
|
||||
|
||||
<group>
|
||||
<group colspan="2">
|
||||
<separator string="Accounts to include" colspan="4"/>
|
||||
<field name="account_list" nolabel="1" colspan="4" domain="[('company_id','=',company_id)]">
|
||||
<tree>
|
||||
<field name='code'/>
|
||||
<field name='name'/>
|
||||
<field name='type'/>
|
||||
</tree>
|
||||
</field>
|
||||
<field name="display_account" required="True"/>
|
||||
<field name="display_account_level" required="True" />
|
||||
</group>
|
||||
<group colspan="2">
|
||||
<separator string="Period" colspan="4"/>
|
||||
<field name="fiscalyear"/>
|
||||
<newline/>
|
||||
<field name="filter" required="True"/>
|
||||
<newline/>
|
||||
|
||||
<group attrs="{'invisible':[('filter','=','none')]}" colspan="4">
|
||||
<group attrs="{'invisible':[('filter','=','byperiod')]}" colspan="4">
|
||||
<separator string="Date Filter" colspan="4"/>
|
||||
<field name="date_from"/>
|
||||
<field name="date_to"/>
|
||||
</group>
|
||||
<group attrs="{'invisible':[('filter','=','bydate')]}" colspan="4">
|
||||
<separator string="Filter on Periods" colspan="4"/>
|
||||
<field name="periods" colspan="4" nolabel="1" domain="[('fiscalyear_id','=',fiscalyear)]"/>
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
<group colspan="4">
|
||||
<newline/>
|
||||
|
||||
<group colspan="4">
|
||||
<separator string="Total" colspan="4"/>
|
||||
<field name="tot_check" colspan="4"/>
|
||||
<field name="lab_str" colspan="4"/>
|
||||
</group>
|
||||
<button name="print_report" string="Print" type="object"/>
|
||||
</group>
|
||||
</group>
|
||||
</form>
|
||||
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_wizard_report" model="ir.actions.act_window">
|
||||
<field name="name">Reporte Balance (Multireportes)</field>
|
||||
<field name="res_model">wizard.report</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="wizard_report_view"/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
|
||||
<menuitem
|
||||
id="menu_wizard_report"
|
||||
name="Reporte Balance (Multireportes)"
|
||||
parent="account.final_accounting_reports"
|
||||
sequence="99"
|
||||
groups="account_financial_report.group_afreport"
|
||||
action="action_wizard_report"/>
|
||||
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -25,8 +25,4 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
##############################################################################
|
||||
|
||||
import wizard_account_balance_4_report
|
||||
import wizard_account_balance_2_report
|
||||
import wizard_account_balance_report
|
||||
|
||||
|
||||
import wizard
|
||||
|
|
|
@ -0,0 +1,162 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
###########################################################################
|
||||
# Module Writen to OpenERP, Open Source Management Solution
|
||||
# Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
|
||||
# All Rights Reserved
|
||||
###############Credits######################################################
|
||||
# Coded by: Humberto Arocha humberto@openerp.com.ve
|
||||
# Angelica Barrios angelicaisabelb@gmail.com
|
||||
# Jordi Esteve <jesteve@zikzakmedia.com>
|
||||
# Javier Duran <javieredm@gmail.com>
|
||||
# Planified by: Humberto Arocha
|
||||
# Finance by: LUBCAN COL S.A.S http://www.lubcancol.com
|
||||
# Audited by: Humberto Arocha humberto@openerp.com.ve
|
||||
#############################################################################
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
##############################################################################
|
||||
|
||||
from osv import osv,fields
|
||||
import pooler
|
||||
import time
|
||||
from tools.translate import _
|
||||
|
||||
class wizard_report(osv.osv_memory):
|
||||
_name = "wizard.report"
|
||||
|
||||
_columns = {
|
||||
'company_id': fields.many2one('res.company','Company',required=True),
|
||||
'account_list': fields.many2many ('account.account','rel_wizard_account','account_list','account_id','Root accounts',required=True),
|
||||
'filter': 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 to use all open fiscal years to compute the balance',required=True),
|
||||
'periods': fields.many2many('account.period','rel_wizard_period','wizard_id','period_id','Periods',help='All periods in the fiscal year if empty'),
|
||||
'display_account': fields.selection([('all','All'),('con_balance', 'With balance'),('con_movimiento','With movements')],'Display accounts'),
|
||||
'display_account_level': fields.integer('Up to level',help='Display accounts up to this level (0 to show all)'),
|
||||
'date_from': fields.date('Start date'),
|
||||
'date_to': fields.date('End date'),
|
||||
'tot_check': fields.boolean('Show Total'),
|
||||
'lab_str': fields.char('Description', size= 128),
|
||||
'inf_type': fields.selection([('bgen','Balance General'),('bcom','Balance Comprobacion'),('edogp','Estado Ganancias y Perdidas'),('bml','Libro Mayor Legal')],'Tipo Informe',required=True),
|
||||
'columns': fields.selection([('one','One Column'),('two','Two Columns'),('four','Four Columns'),('thirteen','Thirteen Columns')],'Column Number',required=True),
|
||||
'currency_id': fields.many2one('res.currency', 'Secondary Currency', help="Forces all values for this report to be expressed in this secondary currency."),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'date_from': lambda *a: time.strftime('%Y-%m-%d'),
|
||||
'date_to': lambda *a: time.strftime('%Y-%m-%d'),
|
||||
'filter': lambda *a:'byperiod',
|
||||
'display_account_level': lambda *a: 0,
|
||||
'inf_type': lambda *a:'bcom',
|
||||
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.invoice', context=c),
|
||||
'fiscalyear': lambda self, cr, uid, c: self.pool.get('account.fiscalyear').find(cr, uid),
|
||||
'display_account': lambda *a:'con_movimiento',
|
||||
'columns': lambda *a:'four',
|
||||
}
|
||||
|
||||
def onchange_filter(self,cr,uid,ids,fiscalyear,filters,context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
res = {}
|
||||
if filters in ("bydate","all"):
|
||||
fisy = self.pool.get("account.fiscalyear")
|
||||
fis_actual = fisy.browse(cr,uid,fiscalyear,context=context)
|
||||
res = {'value':{'date_from': fis_actual.date_start, 'date_to': fis_actual.date_stop}}
|
||||
return res
|
||||
|
||||
def _get_defaults(self, cr, uid, data, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid, context=context)
|
||||
if user.company_id:
|
||||
company_id = user.company_id.id
|
||||
else:
|
||||
company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
|
||||
data['form']['company_id'] = company_id
|
||||
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
|
||||
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
|
||||
data['form']['context'] = context
|
||||
return data['form']
|
||||
|
||||
def _check_state(self, cr, uid, data, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
if data['form']['filter'] == 'bydate':
|
||||
self._check_date(cr, uid, data, context)
|
||||
return data['form']
|
||||
|
||||
def _check_date(self, cr, uid, data, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
|
||||
if data['form']['date_from'] > data['form']['date_to']:
|
||||
raise osv.except_osv(_('Error !'),('La fecha final debe ser mayor a la inicial'))
|
||||
|
||||
sql = """SELECT f.id, f.date_start, f.date_stop
|
||||
FROM account_fiscalyear f
|
||||
WHERE '%s' = f.id """%(data['form']['fiscalyear'])
|
||||
cr.execute(sql)
|
||||
res = cr.dictfetchall()
|
||||
|
||||
if res:
|
||||
if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_from'] < res[0]['date_start']):
|
||||
raise osv.except_osv(_('UserError'),'Las fechas deben estar entre %s y %s' % (res[0]['date_start'], res[0]['date_stop']))
|
||||
else:
|
||||
return 'report'
|
||||
else:
|
||||
raise osv.except_osv(_('UserError'),'No existe periodo fiscal')
|
||||
|
||||
def print_report(self, cr, uid, ids,data, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
|
||||
data = {}
|
||||
data['ids'] = context.get('active_ids', [])
|
||||
data['model'] = context.get('active_model', 'ir.ui.menu')
|
||||
data['form'] = self.read(cr, uid, ids[0])
|
||||
|
||||
if data['form']['filter'] == 'byperiod':
|
||||
del data['form']['date_from']
|
||||
del data['form']['date_to']
|
||||
elif data['form']['filter'] == 'bydate':
|
||||
self._check_date(cr, uid, data)
|
||||
del data['form']['periods']
|
||||
elif data['form']['filter'] == 'none':
|
||||
del data['form']['date_from']
|
||||
del data['form']['date_to']
|
||||
del data['form']['periods']
|
||||
else:
|
||||
self._check_date(cr, uid, data)
|
||||
lis2 = str(data['form']['periods']).replace("[","(").replace("]",")")
|
||||
sqlmm = """select min(p.date_start) as inicio, max(p.date_stop) as fin
|
||||
from account_period p
|
||||
where p.id in %s"""%lis2
|
||||
cr.execute(sqlmm)
|
||||
minmax = cr.dictfetchall()
|
||||
if minmax:
|
||||
if (data['form']['date_to'] < minmax[0]['inicio']) or (data['form']['date_from'] > minmax[0]['fin']):
|
||||
raise osv.except_osv(_('Error !'),_('La interseccion entre el periodo y fecha es vacio'))
|
||||
|
||||
if data['form']['columns'] == 'one':
|
||||
name = 'afr.1cols'
|
||||
if data['form']['columns'] == 'two':
|
||||
name = 'afr.2cols'
|
||||
if data['form']['columns'] == 'four':
|
||||
name = 'afr.4cols'
|
||||
if data['form']['columns'] == 'thirteen':
|
||||
name = 'wizard.report.account.balance.gene'
|
||||
|
||||
print 'NOMBRE DEL REPORTE, ', name
|
||||
|
||||
return {'type': 'ir.actions.report.xml', 'report_name': name, 'datas': data}
|
||||
|
||||
wizard_report()
|
Loading…
Reference in New Issue