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
- Contabilidad
- Inventario
- PoS
- Project
- MRP
Se marcó esta pregunta
1
Responder
7158
Vistas
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
¿Le interesa esta conversación? ¡Participe en ella!
Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.
Registrarse