TypeError attempt to add Decimal + None in Order._balance_paid

Issue #1471 new
Jonathan Zempel
created an issue

The OrderPayment amount field allows NULL. However, the reduce function in Order._balance_paid assumes all amounts are valid Decimal values.

I'm getting a "unsupported operand type(s) for +: 'Decimal' and 'NoneType'" error in Satchmo-0.9.2-py2.6.egg/satchmo_store/shop/models.py in _balance_paid, line 793.

Comments (3)

  1. Jonathan Zempel reporter

    Hi Chris,

    We aren't able to consistently reproduce. The problem manifested in a historical transaction within a large data set. There may have been some administrative edit that cleared the amount field. Either way, if you end up with a NULL amount, it really wreaks havoc in the admin (can't page or search product orders).

  2. Chris Moffitt repo owner

    Try replacing:

        payments = [p.amount for p in self.order.payments.all()]
    

    with

        payments = [Decimal("0.0") if p.amount is None else p.amount for p in self.order.payments.all()]
    

    in line 1320

    Let me know if that works.

  3. Log in to comment