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
- Księgowość
- Zapasy
- PoS
- Project
- MRP
To pytanie dostało ostrzeżenie
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
Podoba Ci się ta dyskusja? Dołącz do niej!
Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!
Zarejestruj się