I am creating saleorder from code and need to know how to set the order_line field which is of one2many type.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Boekhouding
- Voorraad
- PoS
- Project
- MRP
Deze vraag is gerapporteerd
Hi,
First you can create the sale order like this,
sale_id = self.env['sale.order'].create(
{'partner_id': 1,
'date_order': 'value_for_date',
'picking_policy': 'direcr'
})
Add all the necessary/required fields when creating the record.
Now the sale order will get created. Then we have to create the order lines for this sale order,
sale_order_line = self.env['sale.order.line'].create({
'product_id': 1,
'order_id': sale_id.id
})
In the above code you can see that on creating the order lines the value passed to the order_id is the id of the sale order we have created.
Thanks
Thanks
Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!
Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!
Aanmelden