Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
32663 มุมมอง

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

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

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']})

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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 }).

อวตาร
ละทิ้ง

any example using 4,ID?

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ต.ค. 18
9671
1
ก.ย. 22
1839
2
ส.ค. 19
4219
0
ส.ค. 18
4463
4
พ.ค. 18
10590