[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
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user