Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
Hello willie ho,
The value was supposed to be stored in the 'selection' field of the 'ir_model_fields' table (by using the create and write methods of 'ir.model.fields'), but records in that table are actually inserted by direct SQL statements during module installation and the 'selection' column is omitted there, see here: https://github.com/odoo/odoo/blob/8.0/openerp/models.py#L357
You can run the following SQL queries to verify that the selection column is not populated:
-- 'ir.model.fields' has some selection fields, not stored in the DB
SELECT id, model, ttype, name, field_description, selection
WHERE model like 'ir.model.fields'
ORDER BY name;
-- selection is either NULL or empty for all fields in the DB
SELECT id, model, ttype, name, field_description, selection, domain
WHERE selection IS NOT NULL
AND selection NOT LIKE ''
ORDER BY name;
Anyway, you can directly get the 'selection', and also some other field attributes, by directly introspecting the field object, please see the following example
model_name = 'ir.model.fields'
selection_field = 'on_delete'
model_obj = self.pool[model_name]
field_selection = model_obj._columns[selection_field].selection
In the above example I'm obtaining the 'selection' value for the following field: https://github.com/odoo/odoo/blob/8.0/openerp/addons/base/ir/ir_model.py#L267
Not storing the 'selection' values in the database is related to the fact that you can either assign a list, a method reference or even a method name (new since Odoo 8.0) for selection field values. At runtime, the value is appropriately evaluated depending on its type: https://github.com/odoo/odoo/blob/8.0/openerp/fields.py#L1363
See this link for a reference: https://www.odoo.com/documentation/8.0/reference/orm.html#openerp.fields.Selection
About This Community
This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 9/29/15, 9:48 PM|
|Seen: 1777 times|
|Last updated: 9/30/15, 1:30 AM|