Skip to Content
Menu
This question has been flagged
1 Reply
6729 Views


Hello,

I am trying to build an integration between my PHP website and the Odoo ERP of a customer. This customer is building his website using Odoo v11.
My first issue is that Odoo Web Service API Documentation is not available for v11 ^^ (link returns a 404: https://www.odoo.com/documentation/11.0/api_integration.html).

I am trying to create a "sale.order" object into the Odoo of my customer. My customer told me that I have to:

1) create a sale.order (I provide the partner_id)
2) then call the function "onchange_partner_id" on this sale.order so that it autofills some fields on the sale.order

Step 1) is OK but I cannot find how to do step 2). When I read Odoo Web Service API Documentation v8 (https://www.odoo.com/documentation/8.0/api_integration.html) I see that I can only call the "execute_kw" function and I cannot find how to do use it to call the "onchange_partner_id" function.

For Step 1, I do:

order_id = models.execute_kw(db, uid, password, 'sale.order', 'create', [{
    'name': "A new Order", 'partner_id': 17
}])

For Step 2, I tried:

onchange_result = models.execute_kw(db, uid, password, 'sale.order', 'onchange_partner_id', [
    order_id
])
or onchange_result = models.execute_kw(db, uid, password, 'sale.order', 'onchange_partner_id', [[
    order_id
]])

I get an error message "TypeError: cannot marshal None unless allow_none is enabled"

onchange_result = models.execute_kw(db, uid, password, 'sale.order', 'onchange_partner_id', [[
    id: order_id
]])

I get "ERREUR:  syntaxe en entrée invalide pour l'entier : id
  LINE 1: ... "user_id" FROM "sale_order" WHERE "sale_order".id IN ('id')"

onchange_result = models.execute_kw(db, uid, password, 'sale.order', 'onchange_partner_id', [[
    order_id: order_id
]])

I get "TypeError: cannot marshal None unless allow_none is enabled"

Best regards,

Mathieu Ferment

Avatar
Discard
Best Answer

Hello Mathieu! I think you just need to instantiate your xmlrpc client like this:

models = xmlrpc.client.ServerProxy('your_url_here', allow_none=True)
as for step 2, i think this would work:

onchange_result = models.execute_kw(db, uid, password, 'sale.order', 'onchange_partner_id', [
    order_id
]) 
or
onchange_result = models.execute_kw(db, uid, password, 'sale.order', 'onchange_partner_id', [[

    order_id
]).
Avatar
Discard
Related Posts Replies Views Activity
1
Aug 17
7752
2
Dec 23
18947
0
Sep 24
3
0
Sep 24
344
1
Jun 24
659