跳至內容
選單
此問題已被標幟
2 回覆
2618 瀏覽次數

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

頭像
捨棄
最佳答案

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

頭像
捨棄
最佳答案

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

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
2
3月 25
1065
1
4月 24
3021
2
2月 24
3279
1
2月 24
2100
1
3月 24
1475