Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
2231 Lượt xem

Hello Odoo Community,

I am working on automating the sales order creation process in Odoo using Python. I have successfully connected to Odoo using XML-RPC and can create sales orders for products without variants. However, I am struggling to figure out how to include product variants in the sales orders.

  1. Is it possible to create sales orders with product variants using Odoo's external API?
  2. If yes, what are the necessary fields and methods to achieve this?
  3. I recently came across the Odoo Client Library. Does this library simplify the process of working with product variants? If so, how can I get started with it?

Any guidance or examples would be greatly appreciated.

Thank you!


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,
Create a Controller for generating API.
Refer to the below code

sale_order = odoo.env['sale.order'].create({
    'partner_id': partner_id,
    'order_line': [(0, 0, {
        'product_id': product_id,
        'product_uom_qty': quantity,
        'product_uom': product_uom_id,
    })]
})

Hope it helps you

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 5 23
2157
1
thg 3 24
5152
0
thg 2 24
3729
1
thg 6 24
1576
0
thg 2 24
830