From e792a8585805f76d945b6785effe5b680a0d174c Mon Sep 17 00:00:00 2001 From: Stefan Rijnhart Date: Thu, 22 Mar 2012 12:39:59 +0100 Subject: [PATCH] [FIX] Reference to undefined context variable [ADD] Check on 'None' context in account module's sequence override bzr revid: stefan@therp.nl-20120322113959-79wxzej9ih4igg28 --- addons/account/account_bank_statement.py | 2 +- addons/account/account_cash_statement.py | 2 +- addons/account/ir_sequence.py | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index c017ee63da0..adc131efce2 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -341,8 +341,8 @@ class account_bank_statement(osv.osv): if not st.name == '/': st_number = st.name else: + c = {'fiscalyear_id': st.period_id.fiscalyear_id.id} if st.journal_id.sequence_id: - c = {'fiscalyear_id': st.period_id.fiscalyear_id.id} st_number = obj_seq.next_by_id(cr, uid, st.journal_id.sequence_id.id, context=c) else: st_number = obj_seq.next_by_code(cr, uid, 'account.bank.statement', context=c) diff --git a/addons/account/account_cash_statement.py b/addons/account/account_cash_statement.py index 4638d72542e..567af74b59c 100644 --- a/addons/account/account_cash_statement.py +++ b/addons/account/account_cash_statement.py @@ -292,8 +292,8 @@ class account_cash_statement(osv.osv): raise osv.except_osv(_('Error !'), (_('User %s does not have rights to access %s journal !') % (statement.user_id.name, statement.journal_id.name))) if statement.name and statement.name == '/': + c = {'fiscalyear_id': statement.period_id.fiscalyear_id.id} if statement.journal_id.sequence_id: - c = {'fiscalyear_id': statement.period_id.fiscalyear_id.id} st_number = obj_seq.next_by_id(cr, uid, statement.journal_id.sequence_id.id, context=c) else: st_number = obj_seq.next_by_code(cr, uid, 'account.cash.statement', context=c) diff --git a/addons/account/ir_sequence.py b/addons/account/ir_sequence.py index 5c9039e43c3..a98b7e87d77 100644 --- a/addons/account/ir_sequence.py +++ b/addons/account/ir_sequence.py @@ -48,6 +48,8 @@ class ir_sequence(osv.osv): } def _next(self, cr, uid, seq_ids, context=None): + if context is None: + context = {} for seq in self.browse(cr, uid, seq_ids, context): for line in seq.fiscal_ids: if line.fiscalyear_id.id == context.get('fiscalyear_id'):