_ids must be kept with duplicates because it is important to keep the right
order/proximity of records in the cache. But when reading the values, the ids
must be filtered to be unique to not read it twice.

http://codereview.tryton.org/3791002/
This commit is contained in:
?ngel ?lvarez Serra 2014-02-25 10:25:33 +01:00
parent fa61c0b673
commit fc428f7a6c
3 changed files with 51 additions and 0 deletions

25
issue3781003_1_10001.diff Normal file
View File

@ -0,0 +1,25 @@
Index: trytond/model/modelstorage.py
===================================================================
--- a/trytond/trytond/model/modelstorage.py
+++ b/trytond/trytond/model/modelstorage.py
@@ -1269,10 +1269,17 @@
def filter_(id_):
return (name not in self._cache.get(id_, {})
and name not in self._local_cache.get(id_, {}))
+
+ def unique(ids):
+ s = set()
+ for id_ in ids:
+ if id_ not in s:
+ s.add(id_)
+ yield id_
index = self._ids.index(self.id)
ids = chain(islice(self._ids, index, None),
islice(self._ids, 0, max(index - 1, 0)))
- ids = islice(ifilter(filter_, ids), self._cursor.IN_MAX)
+ ids = islice(unique(ifilter(filter_, ids)), self._cursor.IN_MAX)
def instantiate(field, value, data):
if field._type in ('many2one', 'one2one', 'reference'):

View File

@ -0,0 +1,24 @@
Index: invoice.py
===================================================================
--- a/modules/account_invoice/invoice.py
+++ b/modules/account_invoice/invoice.py
@@ -568,13 +568,13 @@
tax_amount[invoice.id] = invoice.currency.round(
tax_amount[invoice.id])
- invoices_move = []
- invoices_no_move = []
+ invoices_move = set()
+ invoices_no_move = set()
for invoice in invoices:
if invoice.move:
- invoices_move.append(invoice.id)
+ invoices_move.add(invoice.id)
else:
- invoices_no_move.append(invoice.id)
+ invoices_no_move.add(invoice.id)
invoices_move = cls.browse(invoices_move)
invoices_no_move = cls.browse(invoices_no_move)

2
series
View File

@ -10,6 +10,8 @@ issue130_392_10919.diff
add_db_client.diff
issue2661002_20001.diff
issue101_226.diff
issue3791002_10002_20001.diff
issue3781003_1_10001.diff
issue3481002_1.diff
issue2731002_20001.diff
issue134_399.diff