From 9fcea67fabafd515dbeb9aef4171c553f6edd801 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Fri, 21 Nov 2008 19:12:24 +0100 Subject: [PATCH] improve bzr revid: fp@tinyerp.com-20081121181224-ms1h2p3nip6w93kx --- bin/osv/fields.py | 1 + bin/osv/orm.py | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/bin/osv/fields.py b/bin/osv/fields.py index dd46d7654fb..9bd2875bcb7 100644 --- a/bin/osv/fields.py +++ b/bin/osv/fields.py @@ -429,6 +429,7 @@ class one2many(_column): for act in values: if act[0] == 0: act[2][self._fields_id] = id + print 'CREATE', self._obj, act[2], context obj.create(cr, user, act[2], context=context) elif act[0] == 1: obj.write(cr, user, [act[1]], act[2], context=context) diff --git a/bin/osv/orm.py b/bin/osv/orm.py index 0acfba66299..75aa1146243 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -116,7 +116,7 @@ class browse_record(object): ''' if not context: context = {} - assert id, _('Wrong ID for the browse record, got %s, expected an integer.') % str(id) + assert id and type(id)==type(1), _('Wrong ID for the browse record, got %s, expected an integer.') % str(id) self._list_class = list_class or browse_record_list self._cr = cr self._uid = uid @@ -128,9 +128,12 @@ class browse_record(object): cache.setdefault(table._name, {}) self._data = cache[table._name] + if not id in self._data: self._data[id] = {'id': id} + self._cache = cache + pass def __getitem__(self, name): if name == 'id': @@ -183,7 +186,7 @@ class browse_record(object): if data[n]: obj = self._table.pool.get(f._obj) compids = False - if not f._classic_write: + if type(data[n]) in (type([]),type( (1,) )): ids2 = data[n][0] else: ids2 = data[n]