Code Monkey home page Code Monkey logo

odoo's Issues

Getting access error

my code is this
`var Odoo = require('../lib/index');

var odoo = new Odoo({
host: '1.2.3.4',
port: 1234,
database: 'abc',
username: 'admin',
password: 'admin'
});

// Connect to Odoo
odoo.connect(function (err) {
if (err) {
return console.log(err);
}

// Get a partner
var params = {
    ids: [1, 2, 3, 4],
    fields: ['name', 'street', 'city', 'email']

};
odoo.get('res.partner', params,
    function (err, partner) {
        if (err) {
            return console.log(err);
        }

        console.log('Partner', partner);
    });

});
`

when I use localhost:8070 for this code, it works fine, but for this ip it gives me this error

{ message: 'Odoo Server Error', code: 200, data: { debug: 'Traceback (most recent call last):\n File "/opt/odoo8/odoo/opener /http.py", line 540, in _handle_exception\n return super(JsonRequest, self). handle_exception(exception)\n File "/opt/odoo8/odoo/openerp/http.py", line 577 in dispatch\n result = self._call_function(**self.params)\n File "/opt/odo 8/odoo/openerp/http.py", line 313, in _call_function\n return checked_call(s lf.db, *args, **kwargs)\n File "/opt/odoo8/odoo/openerp/service/model.py", lin 118, in wrapper\n return f(dbname, *args, **kwargs)\n File "/opt/odoo8/odo /openerp/http.py", line 310, in checked_call\n return self.endpoint(*a, **kw \n File "/opt/odoo8/odoo/openerp/http.py", line 806, in __call__\n return s lf.method(*args, **kw)\n File "/opt/odoo8/odoo/openerp/http.py", line 406, in esponse_wrap\n response = f(*args, **kw)\n File "/opt/odoo8/odoo/addons/web controllers/main.py", line 944, in call_kw\n return self._call_kw(model, met od, args, kwargs)\n File "/opt/odoo8/odoo/addons/web/controllers/main.py", lin 936, in _call_kw\n return getattr(request.registry.get(model), method)(requ st.cr, request.uid, *args, **kwargs)\n File "/opt/odoo8/odoo/openerp/api.py", ine 268, in wrapper\n return old_api(self, *args, **kwargs)\n File "/opt/od o8/odoo/openerp/models.py", line 3144, in read\n result = BaseModel.read(rec rds, fields, load=load)\n File "/opt/odoo8/odoo/openerp/api.py", line 266, in rapper\n return new_api(self, *args, **kwargs)\n File "/opt/odoo8/odoo/open rp/models.py", line 3162, in read\n self.check_access_rights(\'read\')\n Fi e "/opt/odoo8/odoo/openerp/api.py", line 266, in wrapper\n return new_api(se f, *args, **kwargs)\n File "/opt/odoo8/odoo/openerp/api.py", line 487, in new_ pi\n result = method(self._model, cr, uid, *args, **kwargs)\n File "/opt/od o8/odoo/openerp/models.py", line 3505, in check_access_rights\n return self. ool.get(\'ir.model.access\').check(cr, uid, self._name, operation, raise_except on)\n File "/opt/odoo8/odoo/openerp/api.py", line 268, in wrapper\n return ld_api(self, *args, **kwargs)\n File "<decorator-gen-2>", line 2, in check\n ile "/opt/odoo8/odoo/openerp/tools/cache.py", line 122, in lookup\n value = [key] = self.method(*args, **kwargs)\n File "/opt/odoo8/odoo/openerp/addons/ba e/ir/ir_model.py", line 769, in check\n raise openerp.exceptions.AccessError msg % msg_params)\nAccessError: (\'AccessError\', u\'Sorry, you are not allowed to access this document. Only users with the following access level are current y allowed to do that:\\n- Public\\n\\t- Portal\\n\\t- Other/Contact Creation (M mber)\\n\\t- Other/Contact Creation (Team Leader)\\n\\t- Knowledge/User\\n\\t- roject/User\\n\\n(Document model: res.partner)\')\n', exception_type: 'except_osv', message: 'AccessError\nSorry, you are not allowed to access this document. Only users with the following access level are currently allowed to do that:\n- Public\n\t- Portal\n\t- Other/Contact Creation (Member)\n\t- Other/Contact Crea ion (Team Leader)\n\t- Knowledge/User\n\t- Project/User\n\n(Document model: res partner)', name: 'openerp.exceptions.AccessError', arguments: [ 'AccessError', 'Sorry, you are not allowed to access this document. Only users with th following access level are currently allowed to do that:\n- Public\n\t- Portal n\t- Other/Contact Creation (Member)\n\t- Other/Contact Creation (Team Leader)\ \t- Knowledge/User\n\t- Project/User\n\n(Document model: res.partner)' ] } }

is there any solution for this?

Support for https

Hi,
my Odoo is behind an nginx proxy and served over https - the odoo node module only seem to support http.

Enabling https is trivial:
var http = require('http') -> var http = require('https')

and

var client = jayson.client.http(options); -> var client = jayson.client.https(options);

in lib/index.js but obviously this should be done through a configuration option.

Can this be included in the next version please?

Working with 10.0

First of all, let me congratulate for the wonderful job of building this library.

I'm working on an Odoo based project using its last version, 10.0.
Does somebody know a library working on this API version?

Thanks in advance!

Error: connect ETIMEDOUT

There are no connect error handling:

when i try to connect to the wrong odoo server:

var Odoo = require('odoo');

var odoo = new Odoo({
  host: '192.168.1.1',
  database: 'database',
  username: 'username',
  password: 'password'
});

try {
  odoo.connect(function (err) {
    if (err) { return console.log('connect handle error: ',err); }
  });
} catch (err) {
  console.log('connect error: ',err)
}

i've got error:

events.js:141
      throw er; // Unhandled 'error' event
      ^

Error: connect ETIMEDOUT 192.168.1.1:80
    at Object.exports._errnoException (util.js:856:11)
    at exports._exceptionWithHostPort (util.js:879:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1062:14)
[Finished in 21.7s with exit code 1]

I don't know what does if (err) {...} must to handle, but it don't do it well

As you see, this error can't be handled by try {} catch (e) {} construction. There is open issue about it. But i think it wont be close shortly.

Based on comments to issue i linked above, I make a handler. Adding this code:

req.on('error',function (err) {
  cb(err)
});

to Odoo.prototype.connectfunction.

In result - code i've wrote above, logging error instaed of throwing it:

connect handle error:  { [Error: connect ETIMEDOUT 192.168.1.1:80]
  code: 'ETIMEDOUT',
  errno: 'ETIMEDOUT',
  syscall: 'connect',
  address: '192.168.1.1',
  port: 80 }

HTTPS support added

Hi! ๐Ÿ‘‹

Firstly, thanks for your work on this project! ๐Ÿ™‚

Today I used patch-package to patch [email protected] for the project I'm working on.

Lib didn't work with HTTPS, so I added it.

Here is the diff that solved my problem:

diff --git a/node_modules/odoo/lib/index.js b/node_modules/odoo/lib/index.js
index c9eef07..87a70f0 100644
--- a/node_modules/odoo/lib/index.js
+++ b/node_modules/odoo/lib/index.js
@@ -3,6 +3,7 @@
 var assert = require('assert');
 
 var http = require('http'),
+    https = require('https'),
     jayson = require('jayson');
 
 var Odoo = function (config) {
@@ -33,13 +34,18 @@ Odoo.prototype.connect = function (cb) {
     headers: {
       'Content-Type': 'application/json',
       'Accept': 'application/json',
-      'Content-Length': json.length
+      'Content-Length': json.length,
+      'host': this.host
     }
   };
 
   var self = this;
 
-  var req = http.request(options, function (res) {
+  let requestClient;
+  if (this.port === 443) requestClient = https;
+  else requestClient = http;
+
+  var req = requestClient.request(options, function (res) {
     var response = '';
 
     res.setEncoding('utf8');
@@ -188,7 +194,9 @@ Odoo.prototype._request = function (path, params, callback) {
     }
   };
 
-  var client = jayson.client.http(options);
+  let client;
+  if (this.port === 443) client = jayson.client.https(options);
+  else client = jayson.client.http(options);
 
   client.request('call', params, function (e, err, res) {
     if (e || err) {

This issue body was partially generated by patch-package.

error when supplying company_id in call

Good day,

I would like to create an invoice for a particular company ( I have a multi company setup ). When I supply the company_id in the call, then I will get an error depending on what is the current company for the user. If the current company is the same as the one supplied in the call, then there is no error and the invoice is created.

Generally; how do I let odoo know for what company I am performing the call? Must I set the current company for the user before I make the call? Or can I just specify the company in the call, even if current company is different?

Thank you.

JSON.parse error

When odoo server is not working propperly, it can respond anything instaead of data you want.
Like

Internal Server Error

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

Instead of json when postgres is down.

Example of code:

try {
  odoo.connect(function (err) {
    if (err) { return console.log('odoo.connect handle error: ',err); }
  });
} catch (err) {
  console.log('odoo.connect error: ',err);
}

Error throwing:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
^

SyntaxError: Unexpected token <
    at Object.parse (native)
    at IncomingMessage.<anonymous> (D:\work\a.kuntsevich\Dropbox\work\vnc-project\vnc-proj\service\node_modules\odoo\lib\index.js:53:23)
    at emitNone (events.js:72:20)
    at IncomingMessage.emit (events.js:166:7)
    at endReadableNT (_stream_readable.js:905:12)
    at nextTickCallbackWith2Args (node.js:474:9)
    at process._tickCallback (node.js:388:17)
[Finished in 0.7s with exit code 1]

It can't be handled with try{} catch{} construction too

But wrapping response = JSON.parse(response); into try{} catch{} can solve this problem:

try {
  response = JSON.parse(response);
} catch (err) {
  return cb(err, null);
}

in res.on('end', ...) will handle the error instead of throwing it:

odoo.connect handle error:  [SyntaxError: Unexpected token <]

Odoo Session Expired

Hello,
I'm trying to execute some very simple methods but I get this error everytime. Does anyone know where it comes from and how I can solve this ?


{ message: 'Odoo Session Expired',
    code: 100,
    data:
    { 
        debug: 'Traceback (most recent call last):  
                File "/home/odoo/src/odoo/saas-14/odoo/http.py", line 640, in _handle_exception    return super(JsonRequest, self)._handle_exception(exception)  
                File "/home/odoo/src/odoo/saas-14/odoo/addons/base/ir/ir_http.py", line 184, in _dispatch    
                auth_method = cls._authenticate(func.routing["auth"])  
                File "/home/odoo/src/odoo/saas-14/odoo/addons/base/ir/ir_http.py", line 112, in _authenticate    
                getattr(cls, "_auth_method_%s" % auth_method)()  
                File "/home/odoo/src/odoo/saas-14/odoo/addons/base/ir/ir_http.py", line 85, in _auth_method_user    
                raise http.SessionExpiredException("Session expired")
                SessionExpiredException: Session expired',
        exception_type: 'internal_error',
        message: 'Session expired',
        name: 'odoo.http.SessionExpiredException',
        arguments: [ 'Session expired' ] 
    } 
}

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.