[IMP] account: Improve PDF reports to ease the overrides

closes odoo/odoo#128395

Task: 3069324
Related: odoo/enterprise#44052
Related: odoo/upgrade#4942
Signed-off-by: Laurent Smet (las) <las@odoo.com>
This commit is contained in:
Laurent Smet
2023-07-20 20:53:06 +02:00
parent 214ac1f81e
commit 4345ba088d
3 changed files with 34 additions and 17 deletions
+13
View File
@@ -917,6 +917,19 @@ class AccountPayment(models.Model):
lambda l: l.account_id == payment.destination_account_id and not l.reconciled)
lines.reconcile()
def _get_payment_receipt_report_values(self):
""" Get the extra values when rendering the Payment Receipt PDF report.
:return: A dictionary:
* display_invoices: Display the invoices table.
* display_payment_method: Display the payment method value.
"""
self.ensure_one()
return {
'display_invoices': True,
'display_payment_method': True,
}
# -------------------------------------------------------------------------
# BUSINESS METHODS
# -------------------------------------------------------------------------
+7 -7
View File
@@ -108,7 +108,7 @@
<th name="th_description" class="text-start"><span>Description</span></th>
<th name="th_quantity" class="text-end"><span>Quantity</span></th>
<th name="th_priceunit" t-attf-class="text-end {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}"><span>Unit Price</span></th>
<th name="th_price_unit" t-if="display_discount" t-attf-class="text-end {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
<th name="th_discount" t-if="display_discount" t-attf-class="text-end {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
<span>Disc.%</span>
</th>
<th name="th_taxes" t-attf-class="text-start {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}"><span>Taxes</span></th>
@@ -132,23 +132,23 @@
<tr t-att-class="'bg-200 fw-bold o_line_section' if line.display_type == 'line_section' else 'fst-italic o_line_note' if line.display_type == 'line_note' else ''">
<t t-if="line.display_type == 'product'" name="account_invoice_line_accountable">
<td name="account_invoice_line_name"><span t-field="line.name" t-options="{'widget': 'text'}"/></td>
<td class="text-end">
<td name="td_quantity" class="text-end">
<span t-field="line.quantity"/>
<span t-field="line.product_uom_id" groups="uom.group_uom"/>
</td>
<td t-attf-class="text-end {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
<td name="td_price_unit" t-attf-class="text-end {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
<span class="text-nowrap" t-field="line.price_unit"/>
</td>
<td t-if="display_discount" t-attf-class="text-end {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
<td name="td_discount" t-if="display_discount" t-attf-class="text-end {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
<span class="text-nowrap" t-field="line.discount"/>
</td>
<td t-attf-class="text-start {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
<td name="td_taxes" t-attf-class="text-start {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
<span t-out="', '.join(map(lambda x: (x.invoice_label or x.name), line.tax_ids))" id="line_tax_ids"/>
</td>
<td class="text-end o_price_total">
<td name="td_subtotal" class="text-end o_price_total">
<span class="text-nowrap" t-field="line.price_subtotal"/>
</td>
<td t-if="o.tax_calculation_rounding_method == 'round_per_line'" class="text-end o_price_total">
<td t-if="o.tax_calculation_rounding_method == 'round_per_line'" name="td_total" class="text-end o_price_total">
<span class="text-nowrap" t-field="line.price_total"/>
</td>
</t>
@@ -3,10 +3,11 @@
<template id="report_payment_receipt_document">
<t t-call="web.external_layout">
<t t-set="o" t-value="o.with_context(lang=lang)"/>
<t t-set="values" t-value="o._get_payment_receipt_report_values()"/>
<div class="page">
<h3><strong>Payment Receipt: <span t-field="o.name"/></strong></h3>
<div class="mb-4 mt-3">
<div class="row">
<div name="date" class="row">
<div class="col-6" t-if="o.date">
Payment Date: <span t-field="o.date"/>
</div>
@@ -20,7 +21,9 @@
Vendor:
</t><span t-field="o.partner_id"/>
</div>
<div class="col-6" t-if="o.payment_method_id">
<div name="payment_method"
t-if="values['display_payment_method'] and o.payment_method_id"
class="col-6">
Payment Method: <span t-field="o.payment_method_id.name"/>
</div>
</div>
@@ -34,14 +37,15 @@
</div>
</div>
<t t-set="partials" t-value="o.move_id._get_reconciled_invoices_partials()[0]"/>
<t t-set="invoices" t-value="{partial[2].move_id for partial in partials}"/>
<!-- Check if invoices include different currencies -->
<t t-foreach="invoices" t-as="inv">
<t t-if="any(inv.currency_id != par[2].currency_id for par in inv._get_reconciled_invoices_partials()[0])" t-set="otherCurrency" t-value="True"/>
</t>
<table class="table table-sm">
<table name="invoices"
t-if="values['display_invoices']"
class="table table-sm">
<t t-set="partials" t-value="o.move_id._get_reconciled_invoices_partials()[0]"/>
<t t-set="invoices" t-value="{partial[2].move_id for partial in partials}"/>
<!-- Check if invoices include different currencies -->
<t t-foreach="invoices" t-as="inv">
<t t-if="any(inv.currency_id != par[2].currency_id for par in inv._get_reconciled_invoices_partials()[0])" t-set="otherCurrency" t-value="True"/>
</t>
<thead>
<tr>
<th><span>Invoice Date</span></th>