From 6b181b8d589598efd35ac7461115cf4aada99f34 Mon Sep 17 00:00:00 2001 From: Oleksiy Stepaniuk Date: Sat, 27 Apr 2024 11:55:16 +0300 Subject: [PATCH] Fix interface conversion panic for many2one_reference field type (#55) Co-authored-by: Oleksiy Stepaniuk --- conversion.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/conversion.go b/conversion.go index 7addc458..c5879e32 100644 --- a/conversion.go +++ b/conversion.go @@ -129,8 +129,13 @@ func convertFromDynamicToStaticValue(staticType reflect.Type, dynamicValue inter t, _ := time.Parse(format, dynamicValue.(string)) staticValue = NewTime(t) case "Many2One": - name, _ := dynamicValue.([]interface{})[1].(string) - staticValue = NewMany2One(dynamicValue.([]interface{})[0].(int64), name) + if intVal, ok := dynamicValue.(int64); ok { + // for many2one_reference field type + staticValue = NewMany2One(intVal, "") + } else { + name, _ := dynamicValue.([]interface{})[1].(string) + staticValue = NewMany2One(dynamicValue.([]interface{})[0].(int64), name) + } case "Relation": staticValue = NewRelation() staticValue.(*Relation).ids = sliceInterfaceToInt64Slice(dynamicValue.([]interface{}))