summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephane Wirtel <stephane@tinyerp.com>2009-01-29 17:10:22 +0100
committerStephane Wirtel <stephane@tinyerp.com>2009-01-29 17:10:22 +0100
commitf31ce5813ba28150d2f9affc72311626a4ff94b0 (patch)
treeaea5599e80491f19708ee8729327c2825eadab59
parent55ab099cb9475ffaf61578dedc910c6ca80cfb76 (diff)
[FIX] Remove the select for update and use a lock table
lp bug: https://launchpad.net/bugs/314449 fixed bzr revid: stephane@tinyerp.com-20090129161022-6zr4k03d7qil2342
-rw-r--r--bin/addons/base/ir/ir_sequence.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/bin/addons/base/ir/ir_sequence.py b/bin/addons/base/ir/ir_sequence.py
index 31828569d6c..202aac754d2 100644
--- a/bin/addons/base/ir/ir_sequence.py
+++ b/bin/addons/base/ir/ir_sequence.py
@@ -70,14 +70,18 @@ class ir_sequence(osv.osv):
}
def get_id(self, cr, uid, sequence_id, test='id=%s', context={}):
- cr.execute('select id,number_next,number_increment,prefix,suffix,padding from ir_sequence where '+test+' and active=True FOR UPDATE', (sequence_id,))
- res = cr.dictfetchone()
- if res:
- cr.execute('update ir_sequence set number_next=number_next+number_increment where id=%s and active=True', (res['id'],))
- if res['number_next']:
- return self._process(res['prefix']) + '%%0%sd' % res['padding'] % res['number_next'] + self._process(res['suffix'])
- else:
- return self._process(res['prefix']) + self._process(res['suffix'])
+ try:
+ cr.execute('lock table ir_sequence')
+ cr.execute('select id,number_next,number_increment,prefix,suffix,padding from ir_sequence where '+test+' and active=True', (sequence_id,))
+ res = cr.dictfetchone()
+ if res:
+ cr.execute('update ir_sequence set number_next=number_next+number_increment where id=%s and active=True', (res['id'],))
+ if res['number_next']:
+ return self._process(res['prefix']) + '%%0%sd' % res['padding'] % res['number_next'] + self._process(res['suffix'])
+ else:
+ return self._process(res['prefix']) + self._process(res['suffix'])
+ finally:
+ cr.commit()
return False
def get(self, cr, uid, code):