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

Hello All,

My below method for value insertion in one2many field works with the onchange method and the compute method with depends  decorator. But my requirement not full-fill with depends decorator. My method should work with view load. At present method calls, and I tested it with print on the terminal but still value not updated in o2many field.

survey_user_input = fields.One2many('customer.survey', 'partner_id', compute='user_survey_output')

@api.one
def user_survey_output(self):
print('TESSSSSSSSSSSSSSSSSSSS')
Survey_user_input = self.env['survey.user_input']
s_list = []
value = {}
for val in self:
User_input = Survey_user_input.search(['|', ('partner_id', '=', val.id), ('email', '=', val.email)])
for rec in User_input:
data = {'partner_id': val.id,
'user_input_id': rec.id,
'survey_id': rec.survey_id.id,
'date_create': rec.date_create,
'deadline': rec.deadline,
'type': rec.type,
'state': rec.state,
}
s_list.append((0, 0, data))
value.update(survey_user_input=s_list)
print('LLLLLLLLLLLLLLL', value)
return {'value': value}


Thanks in advance.

아바타
취소
베스트 답변

Hi,

You are updating data wrongly. Try to remove these lines

        value.update(survey_user_input=s_list)
print('LLLLLLLLLLLLLLL', value)
return {'value': value}

and update with

self.survey_user_input = s_list


아바타
취소
작성자

Thanks, Hilar

But the still bigger problem is that the above method not work without depends decorator. I want to update the one2may field without depends.

It's not recommended to update one2many fields or many2many in compute function. Better to update this in write function or in onchange function. 

On Mon, 2 Dec 2019, 2:10 pm Pawan Kumar Sharma, <pawan.sharma3992@gmail.com> wrote:

Thanks, Hilar

But the still bigger problem is that the above method not work without depends decorator. I want to update the one2may field without depends.

Sent by Odoo S.A. using Odoo.

관련 게시물 답글 화면 활동
2
2월 20
3217
3
11월 23
16360
0
9월 23
144
1
9월 23
2831
3
11월 24
23330