From 4f11ff379a437f7e8d1e1037037fad92b6795adc Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Mon, 1 Sep 2014 11:39:03 +0200 Subject: [PATCH] [IMP] models: do not prefetch too many records at once --- openerp/models.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/openerp/models.py b/openerp/models.py index 018af58..eaf643e 100644 --- a/openerp/models.py +++ b/openerp/models.py @@ -246,6 +246,9 @@ class NewId(object): IdType = (int, long, basestring, NewId) +# maximum number of prefetched records +PREFETCH_MAX = 200 + # special columns automatically created by the ORM LOG_ACCESS_COLUMNS = ['create_uid', 'create_date', 'write_uid', 'write_date'] MAGIC_COLUMNS = ['id'] + LOG_ACCESS_COLUMNS @@ -3137,6 +3140,9 @@ class BaseModel(object): # fetch the records of this model without field_name in their cache records = self._in_cache_without(field) + if len(records) > PREFETCH_MAX: + records = records[:PREFETCH_MAX] | self + # by default, simply fetch field fnames = {field.name} -- 1.7.10.4