콘텐츠로 건너뛰기
메뉴
신고된 질문입니다
4 답글
4346 화면

Hello guys.

I have a compute field and then I would like to put a search for this field in a view.

I found the documentation in odoov13 that looks  possible :

upper_name = field.Char(compute='_compute_upper', search='_search_upper')

def _search_upper(self, operator, value):
    if operator == 'like':
        operator = 'ilike'
    return [('name', operator, value)]



Then I tried to apply on my code :

sub_state = fields.Char(compute='_get_substate', search='_search_sub_state')



def _get_substate(self):
for batch in self:
batch.sub_state = 'wait'

@api.model
def _search_sub_state(self, operator, operand):
return [('name', operator, operand)]


However I can see in the screen the custom filter with the sub_state but when I put a value there it is  returning nothing.

Do you would know what is missing on my code?

Thank you so much
    

아바타
취소
베스트 답변

Hello, 
Remove the @api.model above the _search_sub_state method.



아바타
취소
베스트 답변

is your computed field stored? If it's not stored, the value only exists in the view, and not in the database where Odoo is searching.

아바타
취소
관련 게시물 답글 화면 활동
1
6월 25
15233
3
4월 25
5358
1
11월 24
1170
Compute Fields 해결 완료
2
7월 24
2251
0
2월 24
28