Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
2112 Tampilan

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

Avatar
Buang
Jawaban Terbai

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()"/>

Avatar
Buang
Jawaban Terbai

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

Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
2
Mar 25
396
1
Apr 24
2039
2
Feb 24
2425
1
Feb 24
1712
1
Mar 24
1474