apply_percentage will fail if a price in the discounted items is None
The code around line 633 in product/models.py will fail with the following exception:
work[lid] = price * percentage / 100
TypeError: unsupported operand type(s) for *: 'NoneType' and 'Decimal'
I was able figure out from the error page that the price was None, the percentage was 20 as expected.
Looking back through the calling code I saw that the item which was being purchased did have a correct price associated, but the shipping's price was currently None. I can guess that this because the error occurred after the first step in the checkout process, before a shipping method is chosen.
I was able to work around this issue by setting the discount to not apply to the shipping at all, but this is undesirable.
The self evident fixes would be to not to attempt to discount prices which are None, or give the shipping price a better default. Assuming the discount will get recalculated as needed the first approach shouldn't cause any other problems.
It is difficult for me to provide a detailed patched since I am not sure who broke the contract, should all prices not be None or should apply_percentage handle None properly?