Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

odoo connection #17

Closed
Pablo-ACF opened this issue Apr 6, 2022 · 5 comments
Closed

odoo connection #17

Pablo-ACF opened this issue Apr 6, 2022 · 5 comments

Comments

@Pablo-ACF
Copy link

Hi, I'm trying to connect a Flutter app to odoo API and I can't seem to be able to make a call to a database I'm trying to use this code,

final test = xml_rpc
        .call(
            url,
            'execute_kw',
            [
              db,
              uid,
              pass,
              'res_partner',
              'search',
              [
                [
                  ['is_company', '=', true]
                ]
              ],
            ],
            encodeCodecs: codecs,
            decodeCodecs: codecs)
        .then((result) => print(result))
        .catchError((error) => print(error));

but I get the No encoder to encode the value I'll leave a link to the odoo documentation for reference.
https://www.odoo.com/documentation/15.0/developer/misc/api/odoo.html

@a14n
Copy link
Owner

a14n commented Apr 6, 2022

If a No encoder to encode the value error occurs it's likely related to the specifics codecs you used. Note that you can skip encodeCodecs/decodeCodecs if you use the standard types of the xmlrpc spec.

Moreover after a quick look at the api, shouldn't it be res.partner instead of res_partner?

@Pablo-ACF
Copy link
Author

Hi thanks for the help, about the res.partner on my odoo instance its named res_partner just cause, and for the No encoder to encode the value I've tried with and without
xml_rpc.intCodec, xml_rpc.boolCodec, xml_rpc.stringCodec, xml_rpc.dateTimeCodec, xml_rpc.base64Codec, xml_rpc.structCodec, xml_rpc.arrayCodec,

@a14n
Copy link
Owner

a14n commented Apr 7, 2022

Assuming db, pass are strings and uid is int, I don't see any reason the following code (without codecs) ends up with the errors No encoder to encode the value.

final test = xml_rpc
        .call(
            url,
            'execute_kw',
            [
              db,
              uid,
              pass,
              'res_partner',
              'search',
              [
                [
                  ['is_company', '=', true]
                ]
              ],
            ])
        .then((result) => print(result))
        .catchError((error) => print(error));

You should try to launch your program in debug mode and follow step by step to understand where this error is coming from.

@Pablo-ACF
Copy link
Author

Pablo-ACF commented Apr 7, 2022

Fixed that error, turns out the uid was instantiated a a Future<void> so there was the error.
Thanks for the help!

@a14n
Copy link
Owner

a14n commented Apr 7, 2022

Glad you find the bug :)

@a14n a14n closed this as completed Apr 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants