|
|
@ -3,7 +3,7 @@ |
|
|
|
# Module Writen to OpenERP, Open Source Management Solution |
|
|
|
# Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>). |
|
|
|
# All Rights Reserved |
|
|
|
###############Credits###################################################### |
|
|
|
# Credits###################################################### |
|
|
|
# Coded by: Humberto Arocha humberto@openerp.com.ve |
|
|
|
# Angelica Barrios angelicaisabelb@gmail.com |
|
|
|
# Jordi Esteve <jesteve@zikzakmedia.com> |
|
|
@ -31,6 +31,7 @@ import pooler |
|
|
|
import time |
|
|
|
from tools.translate import _ |
|
|
|
|
|
|
|
|
|
|
|
class wizard_report(osv.osv_memory): |
|
|
|
_name = "wizard.report" |
|
|
|
|
|
|
@ -87,7 +88,8 @@ class wizard_report(osv.osv_memory): |
|
|
|
res = {'value': {}} |
|
|
|
|
|
|
|
p_obj = self.pool.get("account.period") |
|
|
|
all_periods = p_obj.search(cr,uid,[('fiscalyear_id','=',fiscalyear),('special','=',False)],context=context) |
|
|
|
all_periods = p_obj.search(cr, uid, [('fiscalyear_id', '=', fiscalyear), ( |
|
|
|
'special', '=', False)], context=context) |
|
|
|
s = set(periods[0][2]) |
|
|
|
t = set(all_periods) |
|
|
|
go = periods[0][2] and s.issubset(t) or False |
|
|
@ -109,7 +111,8 @@ class wizard_report(osv.osv_memory): |
|
|
|
context = {} |
|
|
|
context['company_id'] = company_id |
|
|
|
res = {'value': {}} |
|
|
|
cur_id = self.pool.get('res.company').browse(cr,uid,company_id,context=context).currency_id.id |
|
|
|
cur_id = self.pool.get('res.company').browse( |
|
|
|
cr, uid, company_id, context=context).currency_id.id |
|
|
|
res['value'].update({'currency_id': cur_id}) |
|
|
|
return res |
|
|
|
|
|
|
@ -122,8 +125,10 @@ class wizard_report(osv.osv_memory): |
|
|
|
if not company_id: |
|
|
|
return res |
|
|
|
|
|
|
|
cur_id = self.pool.get('res.company').browse(cr,uid,company_id,context=context).currency_id.id |
|
|
|
fy_id = self.pool.get('account.fiscalyear').find(cr, uid,context=context) |
|
|
|
cur_id = self.pool.get('res.company').browse( |
|
|
|
cr, uid, company_id, context=context).currency_id.id |
|
|
|
fy_id = self.pool.get('account.fiscalyear').find( |
|
|
|
cr, uid, context=context) |
|
|
|
res['value'].update({'fiscalyear': fy_id}) |
|
|
|
res['value'].update({'currency_id': cur_id}) |
|
|
|
res['value'].update({'account_list': []}) |
|
|
@ -135,29 +140,39 @@ class wizard_report(osv.osv_memory): |
|
|
|
if context is None: |
|
|
|
context = {} |
|
|
|
res = {'value': {}} |
|
|
|
if not afr_id: return res |
|
|
|
if not afr_id: |
|
|
|
return res |
|
|
|
afr_brw = self.pool.get('afr').browse(cr, uid, afr_id, context=context) |
|
|
|
res['value'].update({'currency_id':afr_brw.currency_id and afr_brw.currency_id.id or afr_brw.company_id.currency_id.id}) |
|
|
|
res['value'].update({ |
|
|
|
'currency_id': afr_brw.currency_id and afr_brw.currency_id.id or afr_brw.company_id.currency_id.id}) |
|
|
|
res['value'].update({'inf_type': afr_brw.inf_type or 'BS'}) |
|
|
|
res['value'].update({'columns': afr_brw.columns or 'five'}) |
|
|
|
res['value'].update({'display_account':afr_brw.display_account or 'bal_mov'}) |
|
|
|
res['value'].update({'display_account_level':afr_brw.display_account_level or 0}) |
|
|
|
res['value'].update({'fiscalyear':afr_brw.fiscalyear_id and afr_brw.fiscalyear_id.id}) |
|
|
|
res['value'].update({'account_list':[acc.id for acc in afr_brw.account_ids]}) |
|
|
|
res['value'].update({ |
|
|
|
'display_account': afr_brw.display_account or 'bal_mov'}) |
|
|
|
res['value'].update({ |
|
|
|
'display_account_level': afr_brw.display_account_level or 0}) |
|
|
|
res['value'].update({ |
|
|
|
'fiscalyear': afr_brw.fiscalyear_id and afr_brw.fiscalyear_id.id}) |
|
|
|
res['value'].update({'account_list': [ |
|
|
|
acc.id for acc in afr_brw.account_ids]}) |
|
|
|
res['value'].update({'periods': [p.id for p in afr_brw.period_ids]}) |
|
|
|
res['value'].update({'analytic_ledger':afr_brw.analytic_ledger or False}) |
|
|
|
res['value'].update({ |
|
|
|
'analytic_ledger': afr_brw.analytic_ledger or False}) |
|
|
|
res['value'].update({'tot_check': afr_brw.tot_check or False}) |
|
|
|
res['value'].update({'lab_str':afr_brw.lab_str or _('Write a Description for your Summary Total')}) |
|
|
|
res['value'].update({'lab_str': afr_brw.lab_str or _( |
|
|
|
'Write a Description for your Summary Total')}) |
|
|
|
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) |
|
|
|
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] |
|
|
|
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) |
|
|
@ -176,7 +191,8 @@ class wizard_report(osv.osv_memory): |
|
|
|
context = {} |
|
|
|
|
|
|
|
if data['form']['date_from'] > data['form']['date_to']: |
|
|
|
raise osv.except_osv(_('Error !'),('La fecha final debe ser mayor a la inicial')) |
|
|
|
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 |
|
|
@ -186,7 +202,8 @@ class wizard_report(osv.osv_memory): |
|
|
|
|
|
|
|
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'])) |
|
|
|
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: |
|
|
@ -220,7 +237,8 @@ class wizard_report(osv.osv_memory): |
|
|
|
del data['form']['date_from'] |
|
|
|
del data['form']['date_to'] |
|
|
|
|
|
|
|
data['form']['periods'] = self.period_span(cr, uid, data['form']['periods'], data['form']['fiscalyear']) |
|
|
|
data['form']['periods'] = self.period_span(cr, uid, data[ |
|
|
|
'form']['periods'], data['form']['fiscalyear']) |
|
|
|
|
|
|
|
elif data['form']['filter'] == 'bydate': |
|
|
|
self._check_date(cr, uid, data) |
|
|
@ -231,7 +249,8 @@ class wizard_report(osv.osv_memory): |
|
|
|
del data['form']['periods'] |
|
|
|
else: |
|
|
|
self._check_date(cr, uid, data) |
|
|
|
lis2 = str(data['form']['periods']).replace("[","(").replace("]",")") |
|
|
|
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 |
|
|
@ -239,7 +258,8 @@ class wizard_report(osv.osv_memory): |
|
|
|
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')) |
|
|
|
raise osv.except_osv(_('Error !'), _( |
|
|
|
'La interseccion entre el periodo y fecha es vacio')) |
|
|
|
|
|
|
|
if data['form']['columns'] == 'one': |
|
|
|
name = 'afr.1cols' |
|
|
|