View - Many2One field as form

Hi
I have a Many2One field - 'follow_up" in a model named “cushing_syndrome”. I want to display this field as a form in the cushing_syndrome model.
Is there any way to display this without migrating the follow_up fields in cushing_syndrom

1 Like

No really. The Many2One API does not allow to show it as a form.
But there are two options to keep the same database schema and still display information:

  • Add Function fields that show data from the target of the Many2One and display them on the form. You can use on_change_with method as getter such that the value will be updated when the Many2One is changed.

  • Add a One2Many Function field that contains just the target of the Many2One. Set a size limit to 1 and display the One2Many as form. Again the getter could also be a on_change_with. If you want to support edition of this form, you will have to define a setter but be careful that the API of One2Many can be complex to support.

1 Like