Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
4701 Visualizzazioni

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)
Avatar
Abbandona
Risposta migliore

Hi,

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

Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
1
apr 19
5660
3
giu 25
823
2
lug 24
2438
1
giu 24
4952
1
ott 23
10619