I'm creating a custom report in the Invoice module.
<span class="text-nowrap" t-esc="doc.invoice_payments_widget" />
I added the above code and it returns jSON format. But I need to get the amount only.
{"title": "Less Payment", "outstanding": false, "content": [{"name": "Customer Payment: INV/2021/0006", "journal_name": "Bank", "amount": 500.0, "currency": "$", "digits": [69, 2], "position": "before", "date": "2021-03-26", "payment_id": 25, "account_payment_id": 2, "payment_method_name": "Manual", "move_id": 11, "ref": "BNK1/2021/0002 (INV/2021/0006)"}]}
There could be more than one payment so you should sum up all amounts of the content
dictionary.
sum([content.get('amount', 0.0)
for content in doc.invoice_payments_widget.get('content', [])])
I would write a method for it, bind that to the report and call it. It would be more clean, too.