示例代码:
data/scheduler.xml
service_card.py
#自动更新服务卡过期状态,每天早上自动执行一次 def
process_change_state(self, cr, uid, ids=None,
context=None):
service_card_ids=self.search(cr,uid,[("state","=",'1')],
context=context)
if
service_card_ids:
DATE_FORMAT =
"%Y-%m-%d"
try:
for rec in self.browse(cr, uid, service_card_ids,
context=context):
if rec.remaining_times == 0:
#已用完
self.write(cr, uid, rec.id,
{'state':'2'})
elif rec.due_date < datetime.datetime.strftime(datetime.date.today(),
DATE_FORMAT):
#已过期
self.write(cr, uid, rec.id,
{'state':'3'})
except
Exception:
_logger.exception("更新服务卡过期状态出现异常!(dispatch.service_card.process_change_state)")
return False
backup_data.xml
手机扫一扫
移动阅读更方便
你可能感兴趣的文章