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

Hi everybody!!

Please i have a field which is a result of a function (fields.function). But my function contains an SQL request and i didnt understand how to create it.

Here is what i have tried:

def _total_get(self, cr, uid, context=None):

cr.execute('select total from hr_payslip_line where code = "22001"')

return cr.fetchall()

Please help

아바타
취소
베스트 답변

Hello


Function field signature:

 (self, cr, uid, ids, field_name, arg, context=None):

and you need to return the result for each id in ids...

So if it's the same for each ids:

dict.fromkeys(ids, result)


==>  You shloud have something like that...

def _total_get(self, cr, uid, ids, fieldname, arg, context=None):
    cr.execute('select total from hr_payslip_line where code = "22001"')
    # supposing you are waiting only one element ??? always for this code 22001 ? 
total = cr.fetchone()[0];
    return dict.fromkeys(ids, total)

 

But it's a strange case... Usually, we want a result distinct according the id given...


Let us know if it's work for you !

아바타
취소
관련 게시물 답글 화면 활동
4
10월 16
31886
1
9월 15
4517
1
6월 15
1444
0
4월 15
1042
2
4월 15
1413