[FIX] Reference to undefined context variable

[ADD] Check on 'None' context in account module's sequence override

bzr revid: stefan@therp.nl-20120322113959-79wxzej9ih4igg28
This commit is contained in:
Stefan Rijnhart 2012-03-22 12:39:59 +01:00
parent 94896a9c0b
commit e792a85858
3 changed files with 4 additions and 2 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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'):