Skip to Content
Menu
This question has been flagged
6 Replies
12418 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();
Avatar
Discard
Best Answer
'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])]

Avatar
Discard
Best Answer

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?

Avatar
Discard
Author Best Answer

Thanks,

this worked:

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

);

....

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

....

Avatar
Discard

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

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

Related Posts Replies Views Activity
3
Dec 22
1653
0
Jun 22
1195
4
Jan 16
9407
1
Mar 15
3268
0
Nov 22
434