[MERGE] account: fix default selection of fiscal year in common report wizard, courtesy of Guewen Baconnier (Camptocamp)

bzr revid: odo@openerp.com-20121219233133-pjrw5r0j1indo9jh
This commit is contained in:
Olivier Dony 2012-12-20 00:31:33 +01:00
commit 7b2460e4e1
1 changed files with 5 additions and 1 deletions

View File

@ -119,12 +119,16 @@ class account_common_report(osv.osv_memory):
return accounts and accounts[0] or False
def _get_fiscalyear(self, cr, uid, context=None):
if context is None:
context = {}
now = time.strftime('%Y-%m-%d')
company_id = False
ids = context.get('active_ids', [])
domain = [('date_start', '<', now), ('date_stop', '>', now)]
if ids and context.get('active_model') == 'account.account':
company_id = self.pool.get('account.account').browse(cr, uid, ids[0], context=context).company_id.id
fiscalyears = self.pool.get('account.fiscalyear').search(cr, uid, [('date_start', '<', now), ('date_stop', '>', now), ('company_id', '=', company_id)], limit=1)
domain += [('company_id', '=', company_id)]
fiscalyears = self.pool.get('account.fiscalyear').search(cr, uid, domain, limit=1)
return fiscalyears and fiscalyears[0] or False
def _get_all_journal(self, cr, uid, context=None):