0

I'm having a strange amount of trouble setting tax_id on Odoo sale.order.line models. My inital code is somewhat like this:

$sale_order_line = $models->execute_kw($info['database'], $info['uid'], $info['password'], 'sale.order.line', 'create', array(
  array(
    'name' => $product['name'],
    'order_id' => (int) $sale_order,
    'product_id' => (int) $product['id'],
    'product_uom' => 1,
    'product_uom_qty' => (float) $line_item->quantity->value(),
    'price_unit' => $product['list_price'],
    'tax_id' => array(13),
  )
));

The id of 13 definitely exists and has been set on order line items created in the front end. I've tried passing it in as a single integer, string, array of integers, array of strings, array of arrays of integers, etc etc, but still no tax_id is set when retrieving the model back again.

I even tried doing a create with no tax and then doing a write afterwards to set the tax, because I thought perhaps with a many2many relationship, that would be the only way to get it to recognise the connection between them, but that didn't work either.

Thanks in advance.

Matt Fletcher
  • 8,182
  • 8
  • 41
  • 60
  • I can't issue a bounty for another two days, so if anyone can help me in the next few hours, I will draw you a delightful picture of your choosing. C'mon, you can't deny that incentive, can you? – Matt Fletcher May 06 '16 at 11:45

1 Answers1

4

As tax_id is the Many2many field , so use can not pass the direct array of id in to it.

use this syntax 'tax_id'=>array(array(6,0,array(13)))

For more info visit my answer here create-a-record-into-many2many-table

I Hope it may solved your issue .

Community
  • 1
  • 1
Prakash Kumar
  • 2,554
  • 2
  • 18
  • 28