Browse Source

status in order change also recorded for multiple selections

php2python
Holger Frey 7 years ago
parent
commit
20e18bed57
  1. 23
      ordr2/views/orders.py

23
ordr2/views/orders.py

@ -24,10 +24,19 @@ from . import update_column_display @@ -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): @@ -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 <em>{!s}</em> updated.'.format(context.model)
request.flash('success', msg)