Technical mailing list archives

Re: Problem with inheriting standard field with type changing

Camptocamp France SAS, Alexandre Fayolle - Camptocamp
- 12/15/2014 03:42:12
On 11/12/2014 12:28, Denis Karataev wrote:
> Hi dear developers,
> When we download and install new version of sources for v7 with new
> bugfixes, we have a problem with iherited fields.
> For example we inherit the field "function" in res.partner model and
> we change type of the field from char to many2one to keep our records
> unique. I mean now we have model res.partner.function with unique
> values and users just select values from the dropdown list on the
> partner form. Ok good, it works, but when we install new sources and
> run database with "-u all", all values for the field become empty! I
> think it's because:
> 1)base module is updated first and in this module the field "function"
> has char type. OpenERP looks into database and there is another type
> of the field, and OpenERP changes the type to char.
> 2)our module is updated next and inherit the field "function" again
> and changes type to many2one.
> It's my thoughts why we get this field empty after every update.
> Please could you give any recommendation how to avoid it, but to have
> "function" with many2one, not char?
> Thank you!

This is not a shortcoming of the ORM, it is a bug in your module. It's
ok-ish to change the type of a column if you don't change it too much
(go from select to char for instance, or text to html) but char to m2o
is way out of bound and will break lots of other modules, so you should
not do that, especially on something with such a large impact as

I advise to add a new column and update the views to hide the old one,
and to make sure you keep the value of the old column synchonized.

Alexandre Fayolle
Chef de Projet
Tel : + 33 (0)4 79 26 57 94

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac Cedex