Reviewers: ,


Please review this at http://codereview.tryton.org/34004/

Affected files:
  M trytond/model/browse.py


Index: trytond/model/browse.py
===================================================================
--- a/trytond/model/browse.py
+++ b/trytond/model/browse.py
@@ -2,6 +2,7 @@
 #this repository contains the full copyright notices and license terms.
 from __future__ import with_statement
 import contextlib
+from itertools import islice, ifilter
 from trytond.model import fields
 from trytond.transaction import Transaction

@@ -89,6 +90,7 @@
                         'does not exist in model "%s"!' \
                         % (name, self._model._name))

+            ffields = {}
             if col.loading == 'eager':
field_access_obj = self._model.pool.get('ir.model.field.access')
                 fread_accesses = {}
@@ -101,17 +103,28 @@
                 to_remove = set(x for x, y in fread_accesses.iteritems()
                         if not y and x != name)

-                ffields = dict((fname, field) for fname, (_, _, field)
-                        in self._model._inherit_fields.iteritems()
-                        if field.loading == 'eager'
-                        and fname not in self._model._columns
-                        and fname not in to_remove)
+                threshold = 100
+                inherit_threshold = threshold - len(self._model._columns)
+                def filter_(fname):
+                    return (fname not in self._data[self._id]
+                        and fname not in self._local_data[self._id])
+                if inherit_threshold > 0:
+                    ifields = islice(ifilter(filter_,
+                        self._model._inherit_fields.iteritems()), 0,
+                        inherit_threshold)
+                    threshold -= inherit_threshold
+ ffields.update(dict((fname, field) for fname, (_, _, field)
+                            in ifields
+                            if field.loading == 'eager'
+                            and fname not in self._model._columns
+                            and fname not in to_remove))
+                ifields = islice(ifilter(filter_,
+                    self._model._columns.iteritems()), 0, threshold)
                 ffields.update(dict((fname, field) for fname, field
-                        in self._model._columns.iteritems()
+                        in ifields
                         if field.loading == 'eager'
                         and fname not in to_remove))
-            else:
-                ffields = {name: col}
+            ffields.update({name: col})

             # add datetime_field
             for field in ffields:


--
[email protected] mailing list

Reply via email to