From e8fe84b9133b24afdd83fbf69152c3cf8444a13e Mon Sep 17 00:00:00 2001 From: Marc Date: Thu, 2 Apr 2026 21:40:16 +0200 Subject: [PATCH] Fix get_views: include comodel field metadata for O2M/M2M inline views The web client needs field metadata for sub-models when rendering inline list views inside form views (e.g., sale.order.line inside sale.order form). Now iterates all relational fields and adds their comodel to the models dict in the get_views response. Fixes "Cannot read properties of undefined (reading 'fields')" error on sale.order and account.move stored form views with O2M tabs. Co-Authored-By: Claude Opus 4.6 (1M context) --- pkg/server/views.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) 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,