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

Hello there,

I would like to display an array with payments details in my customer's invocies.

Can someone helps me to achieve this with Odoo studio or with a selfmade custom module ?

I want to display the payment date, amount and payment method of each payment for 1 invoice at the end of my invoice's report.

I'm using Odoo 16 on Odoo SH.

Thank you in advance,


Aymerick

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi Cybrosys,

Thanks for the code.

I created a custom module for v18 CE to test and managed to install it.

When displaying front end invoice i got this error :

Error while render the template
AttributeError: 'account.move' object has no attribute 'payment_details'
Template: account.report_invoice_document
Path: /t/t/div[2]/div/div[4]/t[2]/t
Node: <t t-esc="o._get_name_invoice_report()"/>

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi

Add this code of invoice template.xml to your custom module

<template id="report_invoice_inherits"
            inherit_id="account.report_invoice_document">

      <xpath expr="//div[@name='payment_term']" position="after">
              <t t-if="o.payment_details">
                 <center><strong style="font-size:20px;">Payment Details</strong></center>
                  <t t-esc="o._get_name_invoice_report()"></t>
                  <br/>
                  <table class="table table-sm o_main_table" name="payment_details_table" style="background-color: #F1F1F1; font-family:Verdana, Arial,sans-serif; color: #454748; width: 100%; border-collapse:separate;">
                      <thead>
                          <tr>
                              <th name="th_sl_no" class="text-center" style="width:50px"><span>SL No</span></th>
                              <th name="th_payment_reference" t-attf-class="text-center {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}" style="width:200px"><span>Payment Ref</span></th>
                              <th name="th_payment_date" t-attf-class="text-center {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}" style="width:100px"><span>Date</span></th>
                              <th name="th_payment_method" t-attf-class="text-center {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}" style="width:140px"><span>Payment Method</span></th>
                              <th name="th_amount_paid" t-attf-class="text-center {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}" style="width:110px"><span>Amount Paid</span></th>
                          </tr>
                      </thead>
                      <tbody class="payment_details_table">
                          <t t-foreach="payments_vals" t-as="value">
                              <tr>
                                  <td><t t-esc="value_index+1"/></td>
                                  <td><t t-esc="value.get('ref')"/></td>
                                  <td><t t-esc="value.get('date')"/></td>
                                  <td><t t-esc="value.get('journal_name')"/></td>
                                  <td><t t-esc="value.get('amount')"/></td>
                              </tr>
                          </t>
                      </tbody>
                  </table>
              </t>
      </xpath>
  </template>





Hope it helps

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 3 25
1273
1
thg 4 24
3327
2
thg 2 24
3605
1
thg 2 24
2298
1
thg 3 24
1475