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

I've tried different solutions from odoo help and stackoverflow but couldn't get any much help.

my code:


start_date = fields.Date()
end_date = fields.Date()
total_months = fields.Char(compute='_total_months')

@api.multi
def _total_months(self):
if self.start_date and self.end_date:
for rec in self:
s_date = dt.strptime(rec.start_date, '%d-%m-%Y')
e_date = dt.strptime(rec.end_date, '%d-%m-%Y')
rec.total_months = str((s_date - e_date).days)
아바타
취소
베스트 답변

Hi,

Please go through this link: How do I calculate number of months between two dates ?

아바타
취소
관련 게시물 답글 화면 활동
1
4월 19
6001
3
6월 25
1386
2
7월 24
3060
1
6월 24
5468
1
10월 23
11303