Skip to Content
Menu
This question has been flagged
3 Replies
1656 Views

Dears,

odoo version 16.

I need create a monthly invoice using API and the same product have diferent taxes on diferent lines . Example:

product 1 = tax_ids 1

product 1 = tax_ids 2

My Postman API POST: 
{{url}}/api/sale.order/create

My Code body:

{ 
"partner_id": 10,
"user_id":6,
"order_line":[
[0,0,{"product_id":6, "product_uom_qty":1,"price_unit": 5,"tax_ids":1}],
[0,0,{"product_id":6, "product_uom_qty":1,"price_unit": 5,"tax_ids":3}]
]
}

My Error message:
200 OK
"success":false,
Error message: "message":"ERROR: ValueError(\"Invalid field 'tax_ids' on model 'sale.order.line'\") {}",

looks the error is the field tax_ids, but I try so many different names like:

  • order_line_tax_ids
  • taxes_ids
  • tax_id
  • tax
  • ...

Please can you clarify the rigth name for tax_ids?

Thanks!

Avatar
Discard
Best Answer

Right field is tax_id

You need to pass tax_id like below:

{ 
"partner_id": 10,
"user_id":6,
"order_line":[
[0,0,{"product_id":6, "product_uom_qty":1,"price_unit": 5,"tax_ids":[(6,0, tax_id_1)]}],
[0,0,{"product_id":6, "product_uom_qty":1,"price_unit": 5,"tax_ids":[(6,0, tax_id_3)]}]
]
}

Meet Dholakia

www.entrivistech.com

Avatar
Discard
Author Best Answer

doesn't work: 500 internal server error.

But also, I try this and I get the next error message:

200 OK
"message":"ERROR: ValueError(\"Invalid field 'tax_ids' on model 'sale.order.line'\") {}",

/{
"partner_id": 10,
"user_id":6,
"order_line":[
[0,0,{"product_id":6, "product_uom_qty":1,"price_unit": 5,"tax_ids":[6,0, {"tax_ids":1}]}],
[0,0,{"product_id":6, "product_uom_qty":1,"price_unit": 5,"tax_ids":[6,0, {"tax_ids":3}]}]
]
}




Avatar
Discard
Best Answer

Hi Meet,

I get Error 500
//span> HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><title>500 Internal Server Errortitle><h1>Internal Server Errorh1><p>The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.p>


thanks!

Avatar
Discard

You are passing the values in wrong way.

With reference to my original answer where you can see tax_id_1 and tax_id_3 should be the actual database id. Here is the example and reference

https://github.com/odoo/odoo/blob/16.0/addons/website_sale/tests/test_website_sale_product_attribute_value_config.py#L289

Related Posts Replies Views Activity
0
Sep 24
3
0
Sep 24
348
1
Jun 24
665
1
Mar 24
924
2
Mar 24
4353