[MERGE] account ir_sequence new api
bzr revid: al@openerp.com-20111001000827-070zkpw85mnadcv1
This commit is contained in:
@@ -32,7 +32,7 @@ import account_analytic_line
|
||||
import wizard
|
||||
import report
|
||||
import product
|
||||
import sequence
|
||||
import ir_sequence
|
||||
import company
|
||||
import res_currency
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ module named account_voucher.
|
||||
'process/statement_process.xml',
|
||||
'process/customer_invoice_process.xml',
|
||||
'process/supplier_invoice_process.xml',
|
||||
'sequence_view.xml',
|
||||
'ir_sequence_view.xml',
|
||||
'company_view.xml',
|
||||
'board_account_view.xml',
|
||||
"wizard/account_report_profit_loss_view.xml",
|
||||
|
||||
@@ -1214,7 +1214,7 @@ class account_move(osv.osv):
|
||||
else:
|
||||
if journal.sequence_id:
|
||||
c = {'fiscalyear_id': move.period_id.fiscalyear_id.id}
|
||||
new_name = obj_sequence.get_id(cr, uid, journal.sequence_id.id, context=c)
|
||||
new_name = obj_sequence.next_by_id(cr, uid, journal.sequence_id.id, c)
|
||||
else:
|
||||
raise osv.except_osv(_('Error'), _('No sequence defined on the journal !'))
|
||||
|
||||
|
||||
@@ -340,9 +340,9 @@ class account_bank_statement(osv.osv):
|
||||
else:
|
||||
if st.journal_id.sequence_id:
|
||||
c = {'fiscalyear_id': st.period_id.fiscalyear_id.id}
|
||||
st_number = obj_seq.get_id(cr, uid, st.journal_id.sequence_id.id, context=c)
|
||||
st_number = obj_seq.next_by_id(cr, uid, st.journal_id.sequence_id.id, context=c)
|
||||
else:
|
||||
st_number = obj_seq.get(cr, uid, 'account.bank.statement')
|
||||
st_number = obj_seq.next_by_code(cr, uid, 'account.bank.statement')
|
||||
|
||||
for line in st.move_line_ids:
|
||||
if line.state <> 'valid':
|
||||
|
||||
@@ -294,9 +294,9 @@ class account_cash_statement(osv.osv):
|
||||
if statement.name and statement.name == '/':
|
||||
if statement.journal_id.sequence_id:
|
||||
c = {'fiscalyear_id': statement.period_id.fiscalyear_id.id}
|
||||
st_number = obj_seq.get_id(cr, uid, statement.journal_id.sequence_id.id, context=c)
|
||||
st_number = obj_seq.next_by_id(cr, uid, statement.journal_id.sequence_id.id, context=c)
|
||||
else:
|
||||
st_number = obj_seq.get(cr, uid, 'account.cash.statement')
|
||||
st_number = obj_seq.next_by_code(cr, uid, 'account.cash.statement')
|
||||
vals.update({
|
||||
'name': st_number
|
||||
})
|
||||
|
||||
@@ -1221,7 +1221,7 @@ class account_move_line(osv.osv):
|
||||
vals['move_id'] = res[0]
|
||||
if not vals.get('move_id', False):
|
||||
if journal.sequence_id:
|
||||
#name = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id)
|
||||
#name = self.pool.get('ir.sequence').next_by_id(cr, uid, journal.sequence_id.id)
|
||||
v = {
|
||||
'date': vals.get('date', time.strftime('%Y-%m-%d')),
|
||||
'period_id': context['period_id'],
|
||||
|
||||
@@ -46,23 +46,14 @@ class ir_sequence(osv.osv):
|
||||
'fiscal_ids': fields.one2many('account.sequence.fiscalyear',
|
||||
'sequence_main_id', 'Sequences')
|
||||
}
|
||||
def get_id(self, cr, uid, sequence_id, test='id', context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
cr.execute('select id from ir_sequence where '
|
||||
+ test + '=%s and active=%s', (sequence_id, True,))
|
||||
res = cr.dictfetchone()
|
||||
if res:
|
||||
for line in self.browse(cr, uid, res['id'],
|
||||
context=context).fiscal_ids:
|
||||
if line.fiscalyear_id.id == context.get('fiscalyear_id', False):
|
||||
return super(ir_sequence, self).get_id(cr, uid,
|
||||
line.sequence_id.id,
|
||||
test="id",
|
||||
context=context)
|
||||
return super(ir_sequence, self).get_id(cr, uid, sequence_id, test,
|
||||
context=context)
|
||||
|
||||
def _next(self, cr, uid, seq_ids, context=None):
|
||||
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'):
|
||||
return super(ir_sequence, self)._next(cr, uid, [line.sequence_id.id], context)
|
||||
return super(ir_sequence, self)._next(cr, uid, seq_ids, context)
|
||||
|
||||
ir_sequence()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
@@ -35,7 +35,7 @@ class account_move(osv.osv):
|
||||
seq_no = False
|
||||
for move in self.browse(cr, uid, ids, context=context):
|
||||
if move.journal_id.internal_sequence_id:
|
||||
seq_no = obj_sequence.get_id(cr, uid, move.journal_id.internal_sequence_id.id, context=context)
|
||||
seq_no = obj_sequence.next_by_id(cr, uid, move.journal_id.internal_sequence_id.id, context=context)
|
||||
if seq_no:
|
||||
self.write(cr, uid, [move.id], {'internal_sequence_number': seq_no})
|
||||
return res
|
||||
|
||||
@@ -674,7 +674,7 @@ class account_voucher(osv.osv):
|
||||
if inv.number:
|
||||
name = inv.number
|
||||
elif inv.journal_id.sequence_id:
|
||||
name = seq_obj.get_id(cr, uid, inv.journal_id.sequence_id.id)
|
||||
name = seq_obj.next_by_id(cr, uid, inv.journal_id.sequence_id.id)
|
||||
else:
|
||||
raise osv.except_osv(_('Error !'), _('Please define a sequence on the journal !'))
|
||||
if not inv.reference:
|
||||
|
||||
@@ -53,9 +53,9 @@ class pos_open_statement(osv.osv_memory):
|
||||
continue
|
||||
|
||||
if journal.sequence_id:
|
||||
number = sequence_obj.get_id(cr, uid, journal.sequence_id.id)
|
||||
number = sequence_obj.next_by_id(cr, uid, journal.sequence_id.id)
|
||||
else:
|
||||
number = sequence_obj.get(cr, uid, 'account.cash.statement')
|
||||
number = sequence_obj.next_by_code(cr, uid, 'account.cash.statement')
|
||||
|
||||
data.update({
|
||||
'journal_id': journal.id,
|
||||
|
||||
Reference in New Issue
Block a user