Order total None causes the admin can not login

Create issue
Issue #1272 resolved
Hynek Cernoch created an issue

Order model has an useful concept of recalculation of all/most prices, if the order total is set to None and the changed order is saved in admin. (useful for setting zero shipping if a customer makes two orders the same day.)

Problem is, that order.total == None raises an exception {{{ unsupported operand type(s) for +: 'Decimal' and 'NoneType' in satchmo_ext/satchmo_toolbar/listeners.py (line 55) newtotal = reduce(operator.add, amounts) }}} The worst case scenario is to set order total to None for any new order in admin, then press "Save" and to close the browser window. Then is no possibility for any user to ever login the web as superuser or staff or continue to do anything on other computers but logout. Even without closing the browser, the only possible activity and the solution is to go back in the history and to set any value to order total.

(It never happened to me, until I deliberately tried it. This is one of the nicest bugs I ever found.)

PATCH {{{ - newtotal = reduce(operator.add, amounts) + newtotal = reduce(operator.add, filter(None, amounts), 0) }}}

Comments (3)

  1. Hynek Cernoch reporter

    There must be at least two new orders in the shop to reproduce it. Any order has the total erased - set to None.

  2. Log in to comment