Search code examples
javaodooxml-rpcodoo-14

Retrieving model fields via Odoo XML-RPC API and false


I successfully retrieved models from "ir.models" and their fields "ir.model.fields" as documented using a Java XML-RPC client. However, the store field of a model fields confuses me. It is often false, e.g. for fields of model res.users like phone, email, zip etc and only a few like login and create_date have it set to true. Is that intended? I mean - according to documentation - store=false marks computed fields but I can still set email when creating a res.users record via the API.

Also, I wonder why unset field values are represented as false via XML-RPC. I cannot distinguish a boolean ttyped field value of false to its unset value?


Solution

  • That's because you have a interesting inheritance situation with res.users.

    This model has an embedded partner by using _inherits = {'res.partner': 'partner_id'} notation in the model definition. In database you will have two tables: res_users and res_partner. The relation between them is made by foreign key partner_id in table res_users.

    But on python side this inheritance will lead to a model res.users which will have all fields of res.partner model, too. And odoo is marking the res.partner fields for model res.users records as not stored, because they are stored in anothers models table.

    For your examples, login and create_date are real res.users fields, so they are stored in res_users table. But phone, email and zip and many more are res.partner fields and stored in table res_partner.