This question has been flagged
1 Reply
4078 Views

I want with a server action (Create Object) to create a new Object Invoice. In fields mapping I set model Invoice and

Destination - Type - Value

Partner - Formula - object.partner_id.id

Journal - Formula - object.journal_id.id

Account - Formula - object.account_id.id

Invoice Lines - Formula - object.invoice_line

I get error for Invoice Lines: KeyError: "Field '0' does not exist in object 'browse_record(account.invoice.line, 80)'" How can I set the value for the Invoice Lines?

Avatar
Discard
Best Answer

For one2many field, You should use 1st option,

1) (0, 0, { values }) - link to a new record that needs to be created with the given values dictionary

2) (1, ID, { values }) - Update the linked record with id = ID (write values on it)

3) (2, ID) - Remove and delete the linked record with id = ID (calls unlink on ID, that will delete the object completely, and the link to it as well)

Example:

[(0, 0, {'field_name':field_value_record1, ...}), (0, 0, {'field_name':field_value_record2, ...})]
Avatar
Discard