콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
32613 화면

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?

관련 게시물 답글 화면 활동
1
10월 18
9605
1
9월 22
1705
2
8월 19
4131
0
8월 18
4422
4
5월 18
10448