VictorYvergniaux
VictorYvergniaux

Reputation: 25

Odoo Validate invoice through API : Request has no attribute session

I am running Odoo on a vps server.

I try to validate an invoice through python XMLrpc using this command

models.execute_kw(db, uid, password, 'account.move', 'action_post',[moveId])

with

models = xmlrpc.client.ServerProxy('{}/xmlrpc/2/object'.format(url))

It works inconsistently. Sometimes it works, sometimes I get this error message that ends with a message

AttributeError: 'Request' object has no attribute 'session'.

On some occasions (no difference between working cases and not working cases) the invoice actually gets validated through API.

I noticed that when I activate / deactivate developper mode, the first invoice i try to validate works but not the ones after

Upvotes: 1

Views: 315

Answers (2)

I recently stumbled upon the same issue, and it seems it's a bug in Odoo 16.0+ that has just been fixed: https://github.com/odoo/odoo/pull/166524

Upvotes: 0

kingofsevens
kingofsevens

Reputation: 540

I don't know if you have any changes in the model but Session errors generally comes from not defining Odoo environment correctly. Please check that. Also as the documentation (Note section) suggests you can use high level APIs.

Upvotes: 0

Related Questions