def create(self, vals):
status_history_obj = self.env['hc.care.plan.status.history']
intent_history_obj = self.env['hc.care.plan.intent.history']
res = super(CarePlan, self).create(vals)
# For Status
if vals and vals.get('status'):
status_history_vals = {
'care_plan_id': res.id,
'status': res.status,
'start_date': datetime.today()
}
if vals.get('status') == 'entered-in-error':
status_history_vals.update({'end_date': datetime.today()})
status_history_obj.create(status_history_vals)
# For Intent
if vals.get('status') != 'entered-in-error':
if vals and vals.get('intent'):
intent_history_vals = {
'care_plan_id': res.id,
'intent': res.intent,
'start_date': datetime.today()
}
intent_history_obj.create(intent_history_vals)
return res
评论列表
文章目录