skilld-labs / go-odoo

Golang wrapper for Odoo API
Apache License 2.0
86 stars 62 forks source link

Interface conversion problem when using FindProductProduct #25

Closed notsukamto closed 4 years ago

notsukamto commented 4 years ago

I encountered a conversion problem when using the FindProductProduct and FindProductProducts. FindProductProductId works fine, just these two.

Here's the method:

pp, err := c.FindProductProducts(odoo.NewCriteria().Add("active", "=", true), odoo.NewOptions().Limit(30))
if err != nil {
    log.Fatal(err)
}

Here's the log:

panic: interface conversion: interface {} is float64, not int64

goroutine 1 [running]:
github.com/skilld-labs/go-odoo.convertFromDynamicToStaticValue(0x1506a20, 0x13e8c60, 0x13c77a0, 0xc0002b3fd0, 0x13e8c60, 0x1)
        /Users/maestro/go/pkg/mod/github.com/skilld-labs/go-odoo@v1.5.0/conversion.go:115 +0x794
github.com/skilld-labs/go-odoo.convertFromDynamicToStaticOne(0xc0002820f0, 0x1506a20, 0x145d6c0, 0x0, 0x145d6c0, 0xc000165000)
        /Users/maestro/go/pkg/mod/github.com/skilld-labs/go-odoo@v1.5.0/conversion.go:95 +0x218
github.com/skilld-labs/go-odoo.convertFromDynamicToStaticSlice(0xc0002ec980, 0x1, 0x1, 0x1506a20, 0x13dbda0, 0x13c2300, 0xc00000ed00, 0x13c2300)
        /Users/maestro/go/pkg/mod/github.com/skilld-labs/go-odoo@v1.5.0/conversion.go:84 +0x7c
github.com/skilld-labs/go-odoo.convertFromDynamicToStatic(0x13c2300, 0xc0002f87a0, 0x13b81a0, 0xc00000eca0, 0xf, 0xc000013d70)
        /Users/maestro/go/pkg/mod/github.com/skilld-labs/go-odoo@v1.5.0/conversion.go:67 +0x3f4
github.com/skilld-labs/go-odoo.(*Client).SearchRead(0xc000182510, 0x14681b9, 0xf, 0xc000195800, 0xc000010560, 0x13b81a0, 0xc00000eca0, 0x13ca920, 0x143e500)
        /Users/maestro/go/pkg/mod/github.com/skilld-labs/go-odoo@v1.5.0/odoo.go:216 +0xd8
github.com/skilld-labs/go-odoo.(*Client).FindProductProducts(0xc000182510, 0xc000195800, 0xc000010560, 0x5, 0xc000111168, 0x13ca9a0)
        /Users/maestro/go/pkg/mod/github.com/skilld-labs/go-odoo@v1.5.0/product_product.go:203 +0x8d
main.main()
        /Users/maestro/Documents/projects/odoo-go/example.go:21 +0x257
exit status 2
ahuret commented 4 years ago

Works well on my side. Note that generated models are based on our own odoo instance (version 11). If you have a different odoo version, model structure could have changed. (I'll add this information on README). You should probably fork the repo and generate yourself the models you need (following https://github.com/skilld-labs/go-odoo#generate-your-models). Generator is version agnostic so it will work well.

notsukamto commented 4 years ago

Thanks for the help! I'm using version 13. It works now using my own model.

ahuret commented 4 years ago

FYI I've updated README in 041a130dd16ce942152ef1049f4bc10589cc335a