[FIX] account: select corresponding fiscal year when changing company on aged partner...
authorMartin Trigaux <mat@openerp.com>
Fri, 26 Jul 2013 09:21:34 +0000 (11:21 +0200)
committerMartin Trigaux <mat@openerp.com>
Fri, 26 Jul 2013 09:21:34 +0000 (11:21 +0200)
lp bug: https://launchpad.net/bugs/1185275 fixed

bzr revid: mat@openerp.com-20130726092134-axwqdopf1ampozcn

1  2 
addons/account/wizard/account_report_common.py

@@@ -34,7 -34,10 +34,10 @@@ class account_common_report(osv.osv_mem
          res = {}
          if chart_account_id:
              company_id = self.pool.get('account.account').browse(cr, uid, chart_account_id, context=context).company_id.id
-             res['value'] = {'company_id': company_id}
+             now = time.strftime('%Y-%m-%d')
 -            domain = [('company_id', '=', company_id),('date_start', '<', now), ('date_stop', '>', now)]
++            domain = [('company_id', '=', company_id), ('date_start', '<', now), ('date_stop', '>', now)]
+             fiscalyears = self.pool.get('account.fiscalyear').search(cr, uid, domain, limit=1)
+             res['value'] = {'company_id': company_id, 'fiscalyear_id': fiscalyears and fiscalyears[0] or False}
          return res
  
      _columns = {
          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
--            domain += [('company_id', '=', company_id)]
 -        else: #use current company id
++        else:  # use current company id
+             company_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id
 -            domain += [('company_id', '=', company_id)]
++        domain = [('company_id', '=', company_id), ('date_start', '<', now), ('date_stop', '>', now)]
          fiscalyears = self.pool.get('account.fiscalyear').search(cr, uid, domain, limit=1)
          return fiscalyears and fiscalyears[0] or False