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