diff --git a/pkg/server/views.go b/pkg/server/views.go index 59b49b7..500d722 100644 --- a/pkg/server/views.go +++ b/pkg/server/views.go @@ -75,13 +75,32 @@ func handleGetViews(env *orm.Environment, model string, params CallKWParams) (in } } - // Build models dict with field metadata + // Build models dict with field metadata. + // Include the main model + all comodels referenced by relational fields. + // Mirrors: odoo/addons/web/models/models.py _get_view_fields() models := map[string]interface{}{ model: map[string]interface{}{ "fields": fieldsGetForModel(model), }, } + // Add comodels (needed for O2M/M2M inline views and M2O dropdowns) + m := orm.Registry.Get(model) + if m != nil { + for _, f := range m.Fields() { + if f.Comodel != "" { + if _, exists := models[f.Comodel]; !exists { + comodelFields := fieldsGetForModel(f.Comodel) + if len(comodelFields) > 0 { + models[f.Comodel] = map[string]interface{}{ + "fields": comodelFields, + } + } + } + } + } + } + return map[string]interface{}{ "views": views, "models": models,