跳至內容
選單
此問題已被標幟
1 回覆
4734 瀏覽次數

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)
頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
1
4月 19
5682
3
6月 25
858
2
7月 24
2452
1
6月 24
4968
1
10月 23
10641