From 0bc2372c2ca4d362f3060d48aad665dca85c4fb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 22 Jan 2009 20:34:39 +0100 Subject: [PATCH] Use a global key for _timestamp in context to work with one2many --- TODO | 1 - trytond/osv/orm.py | 18 ++++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/TODO b/TODO index 9cd51e7cd5..7fadb2d973 100644 --- a/TODO +++ b/TODO @@ -10,4 +10,3 @@ - Change _constraint to pass a BrowseRecordList instead of a list of ids - Change action, menu on res.user into a Many2Many - Add order attribute on page tag -- Allow to pass a context in xxx2xxx operation (it will allow to pass _timestamp) diff --git a/trytond/osv/orm.py b/trytond/osv/orm.py index c3f6edf3e1..2bb203d744 100644 --- a/trytond/osv/orm.py +++ b/trytond/osv/orm.py @@ -1492,9 +1492,10 @@ class ORM(object): ' > %s)' args = [] for i in sub_ids: - if context['_timestamp'].get(i): + if context['_timestamp'].get(self._name + ',' + str(i)): args.append(i) - args.append(context['_timestamp'][i]) + args.append(context['_timestamp'][ + self._name + ',' +str(i)]) if args: cursor.execute("SELECT id " \ 'FROM "' + self._table + '" ' \ @@ -1503,7 +1504,9 @@ class ORM(object): if cursor.rowcount: raise Exception('ConcurrencyException', 'Records were modified in the meanwhile') - del context['_timestamp'] + for i in ids: + if context['_timestamp'].get(self._name + ',' + str(i)): + del context['_timestamp'][self._name + ',' +str(i)] self.pool.get('ir.model.access').check(cursor, user, self._name, 'delete', context=context) @@ -1633,9 +1636,10 @@ class ORM(object): ' > %s)' args = [] for i in sub_ids: - if context['_timestamp'].get(i): + if context['_timestamp'].get(self._name + ',' + str(i)): args.append(i) - args.append(context['_timestamp'][i]) + args.append(context['_timestamp'][ + self._name + ',' +str(i)]) if args: cursor.execute("SELECT id " \ 'FROM "' + self._table + '" ' \ @@ -1644,7 +1648,9 @@ class ORM(object): if cursor.rowcount: raise Exception('ConcurrencyException', 'Records were modified in the meanwhile') - del context['_timestamp'] + for i in ids: + if context['_timestamp'].get(self._name + ',' + str(i)): + del context['_timestamp'][self._name + ',' +str(i)] self.pool.get('ir.model.access').check(cursor, user, self._name, 'write', context=context)