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:
parent
2c62f7868a
commit
2142951174
|
@ -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=[]
|
||||
|
|
Loading…
Reference in New Issue