diff --git a/addons/account/account.py b/addons/account/account.py index 343a418731e..e1ea88399a5 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -453,12 +453,15 @@ class account_fiscalyear(osv.osv): ds = ds + RelativeDateTime(months=interval) return True - def find(self, cr, uid, dt=None, context={}): + def find(self, cr, uid, dt=None, exception=True, context={}): if not dt: dt = time.strftime('%Y-%m-%d') ids = self.search(cr, uid, [('date_start', '<=', dt), ('date_stop', '>=', dt)]) if not ids: - raise osv.except_osv('Error !', 'No fiscal year defined for this date !\nPlease create one.') + if exception: + raise osv.except_osv('Error !', 'No fiscal year defined for this date !\nPlease create one.') + else: + return False return ids[0] account_fiscalyear() diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index f3eda9bc1b2..cca81b2fa4e 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -38,7 +38,7 @@ class account_move_line(osv.osv): def _query_get(self, cr, uid, obj='l', context={}): if not 'fiscalyear' in context: - context['fiscalyear'] = self.pool.get('account.fiscalyear').find(cr, uid) + context['fiscalyear'] = self.pool.get('account.fiscalyear').find(cr, uid, exception=False) return "l.active AND l.state<>'draft' AND l.period_id in (SELECT id from account_period WHERE fiscalyear_id=%d)" % (context['fiscalyear'] ,) def default_get(self, cr, uid, fields, context={}):