_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:
parent
fa61c0b673
commit
fc428f7a6c
|
@ -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'):
|
||||
|
|
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue