rvalyi/ooor — Issue #77: Serialized fields in OpenERP
Author: guewen
Created: 2011-11-02 09:05:14+00:00
State: open

Hi,

With this server branch https://code.launchpad.net/~akretion-team/openobject-server/sparse_field (which I hope will be merged soon), 2 new type of fields are available: sparse and serialized.

Serialized field is used to store data in a field in a json dump

Sparse field use a serialized field to store a field in the json dump instead of a normal database column.

I suppose that the support of sparse fields may be working well because they act like as other fields (string, integer, float, ...).

By cons, the serialized field needs an implementation in ooor.

Actually, when we do a ProductProduct.find(1), we get ;
RuntimeError:

********************************************
*********** OpenERP Server ERROR ***********
warning -- Object Error

Object MagerpVariant doesn't exist
********************************************

Note: the name of the serialized field in product.product is magerp_variant and the value is a Hash

That's because in open_object_resource.rb, in #load (line 311), when the value is a Hash, the key (field name) is converted to an object ( key = magerp_variant => resource = ProductProduct::MagerpVariant)

case value
when Hash
resource = find_or_create_resource_for(key) #TODO check!
@attributes[skey] = resource@attributes[skey].new(value)

Here resource@attributes[skey] is nil.
In which case the code above is used (a type of field) ?

I cannot give a solution as now because I miss the goal of this condition, but I suppose that now 2 different types of fields could return a Hash, and we can no longer rely only on the class of the value; can we check the type (I mean openerp type) of the field ?

Thanks
Guewen