From 1bf0d9abd1c80bb6f6a4d28bb4ca66aad713aa83 Mon Sep 17 00:00:00 2001 From: Oleksiy Stepaniuk Date: Tue, 14 May 2024 12:55:34 +0300 Subject: [PATCH] Fix interface conversion panic for binary field type (#57) Co-authored-by: Oleksiy Stepaniuk --- conversion.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/conversion.go b/conversion.go index c5879e32..ab98c200 100644 --- a/conversion.go +++ b/conversion.go @@ -114,7 +114,13 @@ func convertFromDynamicToStaticValue(staticType reflect.Type, dynamicValue inter if !(dynamicValue == nil || (reflect.ValueOf(dynamicValue).Kind() == reflect.Bool && typeName != "Bool")) { switch typeName { case "String": - staticValue = NewString(dynamicValue.(string)) + if strVal, ok := dynamicValue.(string); ok { + staticValue = NewString(strVal) + } else { + // We use "String" for Odoo Binary field type also, which is used to store binary data. + // However, in rare cases (compute fields), this field might return "[]interface{}" instead of "[]byte". + // @TODO: It's important to handle this scenario as well. + } case "Int": staticValue = NewInt(dynamicValue.(int64)) case "Selection":