0
基於此需求的Openerp 7銷售訂單行剩餘天數計算開始日期減去所有時間。使用的功能字段和換算功能: -行功能值如何在保存記錄前顯示
def _remaining_days(self, cr, uid, ids, field_name, arg, context=None):
res = {}
if not ids:
return {}
for val in self.browse(cr, uid, ids, context=context):
result = datetime.datetime.strptime(val.start_date, '%Y-%m-%d') - datetime.datetime.strptime(current_date, '%Y-%m-%d')
res[val.id] = result.days
return res
'remaining_days': fields.function(_remaining_days, method=True, string='Remaining days', type='integer'),
def onchange_holddays(self, cr, uid, ids, start_date, context=None):
result = {}
context = context or {}
if release_date:
current_date = time.strftime('%Y-%m-%d')
remaining = datetime.datetime.strptime(release_date, '%Y-%m-%d') - datetime.datetime.strptime(current_date, '%Y-%m-%d')
result['remaining_days'] = remaining.days
return {'value': result}
在訂單行剩餘天數值不會自動更新。一旦保存主要銷售訂單記錄,則只更新剩餘天數值。如何在保存記錄之前在列表視圖中顯示剩餘天數值。 Kno