Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
4703 มุมมอง

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 ?

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
Onchange end_date based start_date แก้ไขแล้ว
1
เม.ย. 19
5660
3
มิ.ย. 25
823
2
ก.ค. 24
2438
1
มิ.ย. 24
4953
1
ต.ค. 23
10621