コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
4704 ビュー

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
5660
3
6月 25
824
2
7月 24
2439
1
6月 24
4953
1
10月 23
10622