Cache amounts not cleared on draft
The following scenario fails because the cache on is not cleaned when going back to draft. Same happens on sale. This is the relevant part:
>>> purchase = Purchase()
>>> purchase.party = supplier
>>> purchase.invoice_method = 'order'
>>> purchase_line = PurchaseLine()
>>> purchase.lines.append(purchase_line)
>>> purchase_line.product = product
>>> purchase_line.quantity = 2.0
>>> purchase_line.unit_price = Decimal('5.0000')
>>> purchase.click('quote')
>>> purchase.untaxed_amount
Decimal('10.00')
>>> purchase.click('confirm')
>>> purchase.state
'confirmed'
>>> purchase.click('draft')
>>> purchase.reload()
>>> purchase_line, = purchase.lines
>>> purchase_line.quantity = 10.0
>>> purchase.untaxed_amount
Decimal('50.00')
>>> purchase.click('quote')
>>> purchase.click('confirm')
>>> purchase.reload()
>>> purchase.untaxed_amount
Decimal('50.00')
This is the result on the last purchase.untaxed_amount
Expected:
Decimal('50.00')
Got:
Decimal('10.00')
We need to clean the cached values on transitioning back to draft.