From b4e0ef51ba8f3ca4a7d5c9ae653f283bc33c6a53 Mon Sep 17 00:00:00 2001 From: James Curtis Date: Tue, 27 Oct 2020 14:01:21 +0000 Subject: [PATCH] [FIX] Trace error when transferring a patient When transferring a patient that has their observations stopped, the outstanding observations are cancelled, but the effective_date_terminated value is missing from the written activity vals. This causes a trace error when the frequency of the new obs that is created is updated Fixes #16841 --- nh_activity/activity.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nh_activity/activity.py b/nh_activity/activity.py index ef10799e..bf908c02 100644 --- a/nh_activity/activity.py +++ b/nh_activity/activity.py @@ -615,9 +615,13 @@ def cancel(self, cr, uid, activity_id, context=None): activity_pool = self.pool['nh.activity'] activity = activity_pool.browse(cr, uid, activity_id, context) self.check_action(activity.state, 'cancel') + now = datetime.now().strftime(DTF) activity_pool.write(cr, uid, activity_id, { - 'state': 'cancelled', 'terminate_uid': uid, - 'date_terminated': datetime.now().strftime(DTF)}, context=context) + 'state': 'cancelled', + 'terminate_uid': uid, + 'date_terminated': now, + 'effective_date_terminated': now, + }, context=context) _logger.debug("activity '%s', activity.id=%s cancelled", activity.data_model, activity.id) return True