From 20e18bed57297a98e13382f7e1899a83e462a2c1 Mon Sep 17 00:00:00 2001 From: Holger Frey Date: Wed, 11 Oct 2017 11:43:24 +0200 Subject: [PATCH] status in order change also recorded for multiple selections --- ordr2/views/orders.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/ordr2/views/orders.py b/ordr2/views/orders.py index 63c21c6..264cab4 100644 --- a/ordr2/views/orders.py +++ b/ordr2/views/orders.py @@ -24,10 +24,19 @@ from . import update_column_display def change_in_order_status(request, order, old): ''' notifies a user if a noteworthy change in a order occured ''' noteworthy = False - if old != OrderStatus.ORDERED and order.status == OrderStatus.ORDERED: + + if order.status == OrderStatus.APPROVAL and order.status != old: + order.approval_date = datetime.utcnow() + order.approval_by = request.user.user_name + elif order.status == OrderStatus.ORDERED and order.status != old: noteworthy = True - if old != OrderStatus.COMPLETED and order.status == OrderStatus.COMPLETED: + order.ordered_date = datetime.utcnow() + order.ordered_by = request.user.user_name + elif order.status == OrderStatus.COMPLETED and order.status != old: noteworthy = True + order.completed_date = datetime.utcnow() + order.completed_by = request.user.user_name + if noteworthy: account = request.dbsession.\ query(User).\ @@ -385,16 +394,6 @@ def order_edit_form_processing(context, request): if old_status != order.status: change_in_order_status(request, order, old_status) - if order.status == OrderStatus.APPROVAL: - order.approval_date = datetime.utcnow() - order.approval_by = request.user.user_name - if order.status == OrderStatus.ORDERED: - order.ordered_date = datetime.utcnow() - order.ordered_by = request.user.user_name - if order.status == OrderStatus.COMPLETED: - order.completed_date = datetime.utcnow() - order.completed_by = request.user.user_name - msg = 'Order {!s} updated.'.format(context.model) request.flash('success', msg)