Skip to content

Commit

Permalink
Fix interface conversion panic for many2one_reference field type (#55)
Browse files Browse the repository at this point in the history
Co-authored-by: Oleksiy Stepaniuk <[email protected]>
  • Loading branch information
Stolexiy and Oleksiy Stepaniuk authored Apr 27, 2024
1 parent bdd9a88 commit 6b181b8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}))
Expand Down

0 comments on commit 6b181b8

Please sign in to comment.