Giter VIP home page Giter VIP logo

Comments (9)

a14n avatar a14n commented on May 25, 2024

According to https://www.odoo.com/documentation/15.0/developer/api/external_api.html#pagination I think you should use:

xml_rpc.call(Constants.urlObject, 'execute', [
      Constants.db,
      getStoredUserId,
      getStoredPassword,
      'res.partner',
      'search',
      [
        ['contacto', '=', true]
      ],
      {'limit': 1}
    ])

from dart-xmlrpc.

mdev88 avatar mdev88 commented on May 25, 2024

Thank you for your answer. I have tried that code, but is throwing an exception type 'String' is not a subtype of type 'int' in type cast coming from the file client.dart:

Unhandled Exception: type 'String' is not a subtype of type 'int' in type cast
      decodeResponse (package:xml_rpc/src/client.dart:111:27)
      call (package:xml_rpc/src/client.dart:52:17)
 <asynchronous suspension>
      RPC._getContactsIds (package:tracsa_app/odoo/rpc.dart:117:27)
 <asynchronous suspension>
      RPC.fetchContactsBasicData (package:tracsa_app/odoo/rpc.dart:137:31)
 <asynchronous suspension>
      HomePage.build.<anonymous closure> (package:tracsa_app/pages/home/home_page.dart:48:21)
 <asynchronous suspension> 

I am using verion 0.4.0 of xml_rpc. Let me know if you need more info from my part. Thanks again.

from dart-xmlrpc.

a14n avatar a14n commented on May 25, 2024

It looks like you received an xmlrpc error. According to the response format the fault code should be an int:

The <methodResponse> could also contain a <fault> which contains a <value> which is a <struct> containing two elements, one named <faultCode>, an <int> and one named <faultString>, a <string>.

But the exception you got indicates that this is not the case. It looks like a bug on the server. Could you paste the full xml response you received?

from dart-xmlrpc.

mdev88 avatar mdev88 commented on May 25, 2024

I am using OpenERP 6 on the server side. I am querying a db that is from the actual ERP, is not a custom module or database, so it's pretty standard.

I'm not sure how to see the full xml response, since what is crashing is the actual xml_rpc.call method and I never get al response as a result of calling that method.
I have changed the code a little to try to get as much information as I can, like this:

try {
      var res = await xml_rpc.call(Constants.urlObject, 'execute', [
        Constants.db,
        await _getStoredUserId,
        await _getStoredPassword,
        'res.partner',
        'search',
        [
          ['contacto', '=', true]
        ],
        {'limit': 1}
      ]).onError((error, stackTrace) {
        log('ERROR: $error');
        log('STACKTRACE: : $stackTrace');
      });

      log('RESPONSE: $res');
    } catch (e) {
      log('EXCEPTION: $e');
    }

And then I see in the log:

[log] ERROR: type 'String' is not a subtype of type 'int' in type cast
[log] STACKTRACE: : #0      decodeResponse (package:xml_rpc/src/client.dart:111:27)
#1      call (package:xml_rpc/src/client.dart:52:17)
<asynchronous suspension>
#2      FutureExtensions.onError.<anonymous closure> (dart:async/future.dart:1013:15)
<asynchronous suspension>

[log] RESPONSE: null

I hope this helps...

from dart-xmlrpc.

a14n avatar a14n commented on May 25, 2024

You can set a breakpoint here and observe the value of the body variable.

Alternativelly you can provide a httpPost parameter to call to log the response:

await xml_rpc.call(Constants.urlObject, 'execute', [
        ....
      ], httpPost: (
  Uri url, {
  Map<String, String>? headers,
  Object? body,
  Encoding? encoding,
}) async {
  final response = await http.post(url, headers: headers, body: body, encoding: encoding);
  print(response.body);
  return response;
})

from dart-xmlrpc.

mdev88 avatar mdev88 commented on May 25, 2024

Excellent! Here you go:

<?xml version='1.0'?>
<methodResponse>
<fault>
<value><struct>
<member>
<name>faultCode</name>
<value><string>%d format: a number is required, not dict</string></value>
</member>
<member>
<name>faultString</name>
<value><string>Traceback (most recent call last):
  File "/home/desarrollo/build/server/debian/openerp-server/usr/local/lib/python2.7/site-packages/openerp-server/netsvc.py", line 492, in dispatch
  File "/home/desarrollo/build/server/debian/openerp-server/usr/local/lib/python2.7/site-packages/openerp-server/service/web_services.py", line 611, in dispatch
  File "/home/desarrollo/build/server/debian/openerp-server/usr/local/lib/python2.7/site-packages/openerp-server/osv/osv.py", line 123, in wrapper
  File "/home/desarrollo/build/server/debian/openerp-server/usr/local/lib/python2.7/site-packages/openerp-server/osv/osv.py", line 179, in execute
  File "/home/desarrollo/build/server/debian/openerp-server/usr/local/lib/python2.7/site-packages/openerp-server/osv/osv.py", line 170, in execute_cr
  File "/home/desarrollo/build/server/debian/openerp-server/usr/local/lib/python2.7/site-packages/openerp-server/addons/l10n_es_ar/partner.py", line 383, in search
  File "/home/desarrollo/build/server/debian/openerp-server/usr/local/lib/python2.7/site-packages/openerp-server/osv/orm.py", line 1789, in search
  File "/home/desarrollo/build/server/debian/openerp-server/usr/local/lib/python2.7/site-packages/openerp-server/osv/orm.py", line 4200, in _search
TypeError: %d format: a number is required, not dict
</string></value>
</member>
</struct></value>
</fault>
</methodResponse>

from dart-xmlrpc.

mdev88 avatar mdev88 commented on May 25, 2024

I believe OpenERP requires certain arguments in a specific order. In this case, before limit I might need to add another called offset.

I have tried using {'offset': 0, 'limit': 1} but with this I get Unhandled Exception: type 'String' is not a subtype of type 'int' in type cast

I have also tried {0,1} but with this I get Unhandled Exception: Invalid argument(s): No encoder to encode the value

from dart-xmlrpc.

a14n avatar a14n commented on May 25, 2024

I found a doc for this OpenERP version at https://webcache.googleusercontent.com/search?q=cache:sZW5fX-59WIJ:https://doc.odoo.com/6.1/ru/developer/12_api/ . According to it offset and limit should be provided as parameters. Could you try:

xml_rpc.call(Constants.urlObject, 'execute', [
      Constants.db,
      getStoredUserId,
      getStoredPassword,
      'res.partner',
      'search',
      [
        ['contacto', '=', true]
      ],
      0, // offset
      1, // limit
    ])

from dart-xmlrpc.

mdev88 avatar mdev88 commented on May 25, 2024

Yes!! That worked!
Final code:

await xml_rpc.call(Constants.urlObject, 'execute', [
        Constants.db,
        await _getStoredUserId,
        await _getStoredPassword,
        'res.partner',
        'search',
        [
          ['contacto', '=', true]
        ],
        0,
        1
      ])

Thank you very much!!

from dart-xmlrpc.

Related Issues (14)

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.