How do i store a temporary (NewId) in sale.order.line table? Here is my scenario:
Before converting a quotation to sales order, i need to insert a default product id manually in sales order line upon creation of a quotation. However, it is returning an error: "Missing required field". I checked it and it was "order_id" field from sale.order.line.
Sample code:
# Create SO line - from sales.order (this function will be called when there are changes in default product line)
@api.onchange('default_product_line')
def .....(self):
for line in record.default_product_line:
params = {
'order_id': self.id, # causing error because quotation is not saved yet, still in draft
'name': line.name,
'product_uom_qty': line.qty,
'price_unit': line.price_unit,
'product_id': line.product_id.id
}
self.env['sale.order.line'].create(params)
How can i store sale order line temporarily if a quotation state is still draft?
Please provide more details, I don't see clear exactly what you are doing that have the missing order_id field, how and where? post some code...
Updated the details
I'm sure that I will get errors if I try to run the code you post, why did you put it like that? what it's the value of the record variable?