Coder Social home page Coder Social logo

Comments (3)

jbguerraz avatar jbguerraz commented on July 30, 2024 1

Hello David,

Glad to see you've got interest in that tool :)

The NilableType is indeed kinda tricky.

The main issue is Odoo will send a false if a field is not set; so a field of type
int64 for instance won't be able to cope with such false value.

We could have decided to use only interface{} type and require go-odoo users to type their fields when they need to but instead we decided to go the strongly typed way (so one doesn't have to care much about fields types).

To do so we had to create a nilable structure which uses only interface{} typed fields (except for Booleans for which false isn't an issue) that is used for loading data from Odoo (

func (c *Client) Read(model string, args []interface{}, options interface{}, elem interface{}) error {
-
func (c *Client) SearchRead(model string, args []interface{}, options interface{}, elem interface{}) error {
) and a load method that would inspect the nilable variant of the object in order to create a properly typed one (
func load(ns interface{}, s interface{}) interface{} {
) that will then replace the struct the user passed to the Read / SearchRead methods (
reflect.ValueOf(elem).Elem().Set(reflect.ValueOf(ne.(types.NilableType).Type_()).Elem())
). All of that being transparent to the go-odoo user

Hope that helps :)

Thank you for your contrib efforts on other issues. We surely gonna adopt / contribute with you on those matters in a few (at the moment we're kinda busy).

from go-odoo.

jbguerraz avatar jbguerraz commented on July 30, 2024 1

Done https://github.com/skilld-labs/go-odoo/wiki ;)

from go-odoo.

blaggacao avatar blaggacao commented on July 30, 2024

Wow, could not have been clearer! Copy past to the wiki it! 😉

from go-odoo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.