Odoo Help


PHP XPML-RPC sale.order.line - tax_id

Ramesh Patel
on 4/22/13, 6:35 AM 7,472 views

How can i add tax to an sale.order.line? (version 7)

The order+lines are created "correctly", but without tax.

When i debug in Eclipse I can see that the tax_id string is filled, when using the xml-rpc example below in the osv/orm.py line 4303, but in addons/sale/sale.py line 664:

taxes = tax_obj.compute_all(cr, uid, line.tax_id, price, line.product_uom_qty, line.product_id, line.order_id.partner_id)

line.tax_id contains "list[]".

when creating the same order using the normal web interface line.tax_id reads "browse_record_list: [browse_record(account.tax, 7)]"

Here is my example: ('tax_id'=>new xmlrpcval('[(6, 0, [7, 7])]', 'string'), ) ; Tax id 7, Tax amount 7.

   $OrderPrd = array(

   'name'=>new xmlrpcval($order_name, 'string'),
   'order_id'=>new xmlrpcval($order_id, 'int'),
   'product_id'=>new xmlrpcval($value, 'int'),
   'product_uom_qty'=>new xmlrpcval(5, 'int'),
   'product_uom' =>new xmlrpcval(1, 'int'),
   'product_uos_qty'=>new xmlrpcval(5, 'int'),
   'product_uos' =>new xmlrpcval(1, 'int'),
   'price_unit'=>new xmlrpcval(2000 ,'int'),
   'price_subtotal'=>new xmlrpcval(1000 ,'int'),
   'delay'=>new xmlrpcval(2 ,'float'),
   'tax_id'=>new xmlrpcval('[(6, 0, [7, 7])]', 'string'),  
   'type'=>new xmlrpcval('make_to_stock', 'string'),

     $this->msg = new xmlrpcmsg('execute');
     $this->msg->addParam(new xmlrpcval($this->database, "string"));
     $this->msg->addParam(new xmlrpcval(1, "int"));
     $this->msg->addParam(new xmlrpcval($this->password, "string"));
     $this->msg->addParam(new xmlrpcval("sale.order.line","string"));
     $this->msg->addParam(new xmlrpcval("create", "string"));
     $this->msg->addParam(new xmlrpcval($OrderPrd, "struct"));

     $this->res = &$this->client->send($this->msg);
     $order_id_line[] = $this->res->value()->scalarval();

Francesco OpenCode

--Francesco OpenCode--

| 6 8 9
Grottaglie, Italy
--Francesco OpenCode--

Italian Odoo (OpenERP) Modules Developer LINKEDIN: http://www.linkedin.com/in/francescoapruzzese

Francesco OpenCode
On 4/22/13, 6:46 AM
'tax_id'=>new xmlrpcval('[(6, 0, [7, 7])]', 'string'),

Must be an array and not a string

Create before the array for [7, 7] and the the array for [(6, 0, [7, 7])]

On 5/25/16, 8:07 AM

This is a great question, but I don't quite understand you guys. I'm trying to do this in python, so what kind of tuple is expected from me? This doesn't work:

'tax_ids':[0, 0, {myline['erp_tax_id']}]

What do these numbers 6 and 7 mean in OPs example?

Ramesh Patel
On 4/22/13, 8:32 AM


this worked:

    $tax = array(new xmlrpcval(
            new xmlrpcval(6, "int"),// 6 : id link
            new xmlrpcval(0, "int"), 
            new xmlrpcval(array(new xmlrpcval(7, "int")),"array")



'tax_id'=>new xmlrpcval($tax, 'array'),


If my answer is the correct one, please set it as correct to help future users search.

Francesco OpenCode
on 4/22/13, 8:52 AM

Is ist possible for someone to explain this code, I'm trying to convert it in C#, don't understand the array (multi dimensional) from where comes the 6 or 7 thank you

Marc Wagener
on 10/8/14, 11:25 AM

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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 4/22/13, 6:35 AM
Seen: 7472 times
Last updated: 5/25/16, 8:07 AM