When creating records with magic number (0, 0, values) the response doesn't include the id of the new record so it is not cached.
Maybe call read on the field?
Ideally, we should store fields names in the values so we read only them when we resolve the initial call.
ex:
invoice_vals = {
'partner_id': partner_id.id,
'date_invoice': '2023-05-12',
'type': 'out_invoice',
'invoice_line_ids': [
(0, 0, {
'product_id': env['product.product'].search([('name', '=', 'Product A')], limit=1).id,
'quantity': 5,
'price_unit': 10.0,
}),
(0, 0, {
'product_id': env['product.product'].search([('name', '=', 'Product B')], limit=1).id,
'quantity': 3,
'price_unit': 15.0,
}),
],
}
invoice = env['account.move'].create(invoice_vals)
After the create/write initial call, we should read invoice_line_ids on the invoice, then read product_id, quantity, price_unit on the invoice lines.
When creating records with magic number
(0, 0, values)the response doesn't include the id of the new record so it is not cached.Maybe call read on the field?
Ideally, we should store fields names in the values so we read only them when we resolve the initial call.
ex:
After the create/write initial call, we should read
invoice_line_idson the invoice, then readproduct_id, quantity, price_uniton the invoice lines.