This question has been flagged
1 Reply
1932 Views

Hello everyone.. i have 3 tables estimation info , project details and add task in estimation info i have field called project_detail_ids which is o2m field of project details table in project details table i have three fields task id(m2o field of add task table),hour and notes i want to insert data in project_detail_ids any have any idea how can i insert data in m2o( task_id) field which is inside one2many field.

Avatar
Discard
Best Answer

Hi,
You can create,update,delete values on the one2many field as follows:

(0, 0, { values }) - link to a newvrecord 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 same as 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)

In this case you can use (0, 0, { values }) and on the ‘values’ you can give the fields and its values as a key:value format.

For example you can give it as follows:

project_details_list = []

project_details_list.append(
(0,0,{
‘task_id’: id of the task,
‘hour’: hour,
‘note’: note,
}
)
)
project_details_ids = project_details_list

Regards

Avatar
Discard