Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
6678 Lượt xem

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)"}]}

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất
<t t-set="total" t-value="0"/>
<t
t-set="payments_vals" t-value="doc.sudo()._get_reconciled_info_JSON_values()"/>
<t
t-foreach="payments_vals" t-as="payment_vals">
<t
t-set="total" t-value="total + payment_vals['amount']" />
</t>
<span
class="text-nowrap" t-esc="total" />

there will be cases where you will have more than one payment line. So its better to use the above code.
Ảnh đại diện
Huỷ bỏ
Tác giả

Is it possible to display the currency as well?

<span class="text-nowrap" t-esc="total" t-options='{"widget": "monetary", "display_currency": doc.currency_id}' />

Tác giả

Thank you! My first time to develop in Odoo.

Câu trả lời hay nhất

Hello 

In json format you are getting the "account_payment_id". so using this account payment id you will get amount from the account payment.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 3 25
1375
4
thg 4 24
174280
0
thg 12 23
2172
5
thg 7 25
228059
1
thg 8 23
4577