Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
Working on pushing orders to open erp from our webshops orders but getting an error in open erp xmlrpc request .
I received instructions to make this request to open erp:
I created this in PHP to test:
$order_line_items = array( 'product_cod' => new xmlrpcval('ZWWX4135', "string") ,
'qty' => new xmlrpcval('1.0', "string") ,
'price_unit' => new xmlrpcval('166.00', "string") ,
'discount_pct' => new xmlrpcval('0.0', "string") ,
'taxes' => new xmlrpcval('16.44', "string") ,
'tax_included' => new xmlrpcval('true', "string")
And then in request:
'lines' => new xmlrpcval($order_line_items, "struct") ,
But then I get an error:
File "/opt/openerp-6.1-extra-addons/mod_ext/remote/remote_sync.py", line 303, in _import_sale_order product_ids=product_obj.search(cr,uid,[('default_code','=',payload_line['product_cod'])],context=context) TypeError: string indices must be integers, not str
Hopefully someone can point me in the right direction. Any help is highly appreciated! Thanks, Bas
the 'lines' attribute is a one2many field. In order to update values on this, you need to use a special syntax as defined in https://www.odoo.com/documentation/8.0/reference/orm.html#openerp.models.Model.write
In python you must pass an array of tuples like this:
In php, this will get quite messy unfortunately because you must encapelate everything in a huge stack of xmrpcval objects. The value you need to pass is actualy a list of tuples containing dictionairies, in php this will be an array of arrays containing structs.
At the time I was new to xml-rpc / odoo, and the PHP xml-rpc library documentation is very limited and it didn't answer my question.
However, solution was quite simple and completely inline with your answer...
This did the trick:
$order_line_items = new xmlrpcval(array(
'product_cod' => new xmlrpcval("ZZZE1090", "string") ,
'name' => new xmlrpcval($transport_name, "string") ,
'qty' => new xmlrpcval("1", "double") ,
'price_unit' => new xmlrpcval($shipping_ex_vat, "double") , // incl BTW
'discount_pct' => new xmlrpcval('0.0', "double") ,
'taxes' => new xmlrpcval('0.00', "double") ,
'tax_included' => new xmlrpcval('0', "boolean")
And in calling the payload:
'lines' => new xmlrpcval($order_line_items, "array") ,
However, if I run into similar problem in future, I know who to ask ;-)
Enjoy the holidays!
About This Community
This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 11/13/13, 7:34 AM|
|Seen: 2926 times|
|Last updated: 3/16/15, 8:10 AM|