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

I have a field linked with  Vehicle_id this  Vehicle had a product 

when I chose any  Vehicle I need to add it to the order line

when I save the record i got it "

Missing required fields on accountable sale order line.

my code :

@api.onchange('vehicle_id')

    def_add_product(self):

        lines=[]

        vals={}

        forrecinself:

            ifrec.vehicle_id:

                product=self.env['fleet.vehicle'].search([('id' , '=' ,rec.vehicle_id.id)]) 

               print('product >>>' + str(product.product))

                asd=product.product 

               vals = { 

                      'product_id' : asd.id 

,                     'order_id': id,
                    'name': asd['name'],
                    'product_uom_qty':  1,
                    'price_unit': 1,

                     'product_uom_qty' : 1

              }    

                lines.append((0,0,vals))

                rec.order_line = lines

 


 


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

Hi Ali Ammar,

Please add  product_uom (Unit of Measure) in the order line dictionary.  As you are creating the sale order line, then you must have a value of product and UOM in the line.

Hope it will help you.

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

Thanx
It work now

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 11 23
1200
2
thg 3 24
4514
1
thg 3 23
2449
0
thg 10 22
2760
Open a URL Đã xử lý
2
thg 10 22
6880