skilld-labs / go-odoo

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

Fix interface conversion panic for binary field type #57

Closed Stolexiy closed 4 months ago

Stolexiy commented 4 months ago

Hello,

This pull request fixes a panic error that occurs when attempting to get an entity with a field of type "binary" in a model. The "binary" field is typically used to store binary data, such as images or files, directly in the database.

But in some rare cases, this type of field can be used in another way. I faced the issue when tried to access a model that contains compute, non-stored binary field (amount_by_group in sale.order model in Odoo 13, or tax_totals in account.move model in Odoo 17).

The error occurs because the conversion logic expects a string, but in this case, it's receiving an []interface{} instead. This fix only ensures that string conversion errors will not cause panic. It might be worth introducing a new Binary field type to the go-odoo where we can handle the correct conversion for such compute fields.

Error: interface conversion: interface {} is []interface {}, not string

ahuret commented 4 months ago

LGTM