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

Thank very much before hand.


Im using Odoo 17 

Im triying to add a product to sale order with python code from automated action, but ever a get an error from Odoo 17.

This is my code :

inv_lines = []

tmp = {

        "product_template_id": 'test',

        "name": 'test',

        "product_uom_qty": 1,

        'price_unit': 3,

    }

inv_lines.append((0, 0, tmp))

self.env['sale.order'].create(inv_lines)



 

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

While creating a sale order, partner_id is required. Specify the product using product_id. Provide the id of the product and customer instead of using the name directly. For example, refer to the below code:

sale_order = self.env['sale.order'].create({

            'partner_id': self.partner_id.id,

            'order_line': [(0, 0, {

                'product_id': self.env['product.product'].search([('name', '=', 'test')], limit=1).id,

                'name': 'test',

                'product_uom_qty': 1,

                'price_unit': 3.00,

            })],

        })


Hope it helps

Ảnh đại diện
Huỷ bỏ
Tác giả

Thank you very much.

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 9 24
22
1
thg 9 24
1113
3
thg 9 24
1722
1
thg 7 25
525
0
thg 11 24
1243