This question has been flagged
2 Replies
31078 Views

for example my one2many values like this

[[0, False, {u'user_id': 1, u'action_id': 1}, False], [0, False, {u'user_id': 7, u'action_id': 2}]]

i want to append some values in the list of list of dictionary. 

I want to add 'partner_id': 47, 'email': 'roshan@amzsys.com', this to all records.How it is possible.
Please how to get the answer. Thanks in advance

Avatar
Discard
Author Best Answer

I override the create method and add this. Here i can update the values.

tasks = vals['tasks_ids']

        for record in tasks:

            record[2].update({'partner_id': vals['partner_id'], 'partner_phone': vals['partner_phone'],

                       'email': vals['email'],'source_id': vals['source_id'],

                       'partner_id': vals['partner_id'],'service_id': vals['service_id']})

Avatar
Discard
Best Answer

hi,

to write to one2many field use :

(0, 0,  { values })    link to a new record that needs to be created with the given values dictionary
(1, ID, { values })    update the linked record with id = ID (write *values* on it)
(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)
(3, ID)                cut the link to the linked record with id = ID (delete the relationship between the two objects but does not delete the target object itself)
(4, ID)                link to existing record with id = ID (adds a relationship)
(5)                    unlink all (like using (3,ID) for all linked records)
(6, 0, [IDs])          replace the list of linked IDs (like using (5) then (4,ID) for each ID in the list of IDs)

i dont know where you want to add this, but i think you need to go with (1, ID, { values }).

Avatar
Discard

any example using 4,ID?