Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
4724 Widoki

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)
Awatar
Odrzuć
Najlepsza odpowiedź

Hi,

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

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
kwi 19
5674
3
cze 25
838
2
lip 24
2447
1
cze 24
4964
1
paź 23
10631