[FIX]:sequence might use a child company's sequence by error under certain circumstances, use force_company in the context if you want specific companies seq to used else use users current company seq
lp bug: https://launchpad.net/bugs/863221 fixed bzr revid: nch@tinyerp.com-20111114110447-jn71htdyx5q4gqiu
This commit is contained in:
parent
c90146707f
commit
e99921e853
|
@ -189,7 +189,14 @@ class ir_sequence(openerp.osv.osv.osv):
|
|||
def _next(self, cr, uid, seq_ids, context=None):
|
||||
if not seq_ids:
|
||||
return False
|
||||
seq = self.read(cr, uid, seq_ids[:1], ['implementation','number_next','prefix','suffix','padding'])[0]
|
||||
if context is None:
|
||||
context = {}
|
||||
force_company = context.get('force_company')
|
||||
if force_company is None:
|
||||
force_company = self.pool.get('res.users').browse(cr, uid, uid).company_id.id
|
||||
sequences = self.read(cr, uid, seq_ids, ['company_id', 'implementation','number_next','prefix','suffix','padding'])
|
||||
preferred_sequences = [s for s in sequences if s['company_id'] and s['company_id'][0] == force_company ]
|
||||
seq = preferred_sequences[0] if preferred_sequences else sequences[0]
|
||||
if seq['implementation'] == 'standard':
|
||||
cr.execute("SELECT nextval('ir_sequence_%03d')" % seq['id'])
|
||||
seq['number_next'] = cr.fetchone()
|
||||
|
|
Loading…
Reference in New Issue