Concurrency check on write : if two read-write cycle are interleaved the server is able to detect them and to warn the user.

bzr revid: bch-e37b9f6fcc6e48ce90b4680f4f123250f6255028
This commit is contained in:
bch 2007-05-08 13:33:14 +00:00
parent 2c62f7868a
commit 2142951174
1 changed files with 8 additions and 1 deletions

View File

@ -848,12 +848,19 @@ class orm(object):
# TODO: Validate
#
def write(self, cr, user, ids, vals, context={}):
delta= context.get('read_delta',False)
if delta:
cr.execute("select (now() - '%s'::interval - min(write_date)) >= '0'::interval from %s where id in (%s)"% (delta,self._table,",".join(map(str, ids))) )
res= cr.fetchall()
if res and (res.pop()[0] == 0):
raise except_orm('ConcurrencyException', 'This record was modified in the meanwhile')
self.pool.get('ir.model.access').check(cr, user, self._name, 'write')
#for v in self._inherits.values():
# assert v not in vals, (v, vals)
if not ids:
return
ids_str = string.join(map(lambda x:str(x), ids),',')
ids_str = string.join(map(str, ids),',')
upd0=[]
upd1=[]
upd_todo=[]