我正在发票模块中创建自定义报告
<span class="text-nowrap" t-esc="doc.invoice_payments_widget" />
我添加了上面的代码,它返回jSON格式。但是我只需要得到数量
{"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)"}]}
如果返回json,首先需要使用json库将其转换为Python结构:
从那里你可以使用标准代码,比如CZoellner。如果您不理解这个答案,可以查找Python的“列表理解”
可能有多笔付款,因此您应该汇总
content
字典的所有金额我会为它编写一个方法,将它绑定到报告并调用它。它也会更干净
相关问题 更多 >
编程相关推荐