From 86acc1a62ffd1bdbbf79a6d315287baf5a5cea2b Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Thu, 12 Jun 2014 16:14:41 +0200 Subject: [PATCH] [FIX] orm: avoir errors reading twice a field _read_flat: remove duplicated fields in read call get many2one: as False is instance of int, check the value of x first to avoid calling a name_get with a list of False When we were reading twice a m2o field where at least one result is null, the first call to name_get would set the value to False instead of None and then accepted by the filter 'isinstance(x, (int,long))' --- openerp/osv/fields.py | 2 +- openerp/osv/orm.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/openerp/osv/fields.py b/openerp/osv/fields.py index 18aa3aad8c2..49421365852 100644 --- a/openerp/osv/fields.py +++ b/openerp/osv/fields.py @@ -464,7 +464,7 @@ class many2one(_column): # we use uid=1 because the visibility of a many2one field value (just id and name) # must be the access right of the parent form and not the linked object itself. records = dict(obj.name_get(cr, SUPERUSER_ID, - list(set([x for x in res.values() if isinstance(x, (int,long))])), + list(set([x for x in res.values() if x and isinstance(x, (int,long))])), context=context)) for id in res: if res[id] in records: diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py index 6e91ba46721..1dbac53511f 100644 --- a/openerp/osv/orm.py +++ b/openerp/osv/orm.py @@ -3694,6 +3694,8 @@ class BaseModel(object): return [] if fields_to_read is None: fields_to_read = self._columns.keys() + else: + fields_to_read = list(set(fields_to_read)) # all inherited fields + all non inherited fields for which the attribute whose name is in load is True fields_pre = [f for f in fields_to_read if