From 5f5bb5e26b0cf49dc48d00eeac80fa25bca315c5 Mon Sep 17 00:00:00 2001 From: Adrian Torres Date: Mon, 18 Feb 2019 14:28:57 +0000 Subject: [PATCH] [FIX] ir_model_fields: register selection options Before this commit: -> Debug mode -> Settings -> Database structure -> Fields -> Any selection field => The field `selection` of the ir.model.fields form view does not display the selection options of the field being viewed, this is because the selection field is not registered at `_reflect_field_params` of `ir.model.fields`. After this commit: The field is properly registered; for Selection fields with static options, these are shown as-is, for fields with a lambda function as options, the string 'function' is displayed, and for fields using a function name as a string, the same string will be displayed. Fixes #28360 closes odoo/odoo#31207 --- odoo/addons/base/ir/ir_model.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/odoo/addons/base/ir/ir_model.py b/odoo/addons/base/ir/ir_model.py index 7f94d6649c8..9e63d6919b2 100644 --- a/odoo/addons/base/ir/ir_model.py +++ b/odoo/addons/base/ir/ir_model.py @@ -742,6 +742,10 @@ class IrModelFields(models.Model): def _reflect_field_params(self, field): """ Return the values to write to the database for the given field. """ model = self.env['ir.model']._get(field.model_name) + selection = getattr(field, 'selection', None) + if not isinstance(selection, list): + # only reflect the selection of a selection field if it's a list + selection = None return { 'model_id': model.id, 'model': field.model_name, @@ -759,6 +763,7 @@ class IrModelFields(models.Model): 'readonly': bool(field.readonly), 'required': bool(field.required), 'selectable': bool(field.search or field.store), + 'selection': selection, 'size': getattr(field, 'size', None), 'translate': bool(field.translate), 'relation_field': field.inverse_name if field.type == 'one2many' else None,