Skip to Content
Menu
This question has been flagged
1 Reply
1924 Views

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

 


 


Avatar
Discard
Best Answer

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.

Avatar
Discard
Author

Thanx
It work now

Related Posts Replies Views Activity
0
Nov 23
449
2
Mar 24
2330
1
Mar 23
1338
0
Oct 22
1615
2
Oct 22
4997