Skip to content

Commit

Permalink
[IMP] sale_commission: print partial and document total in report
Browse files Browse the repository at this point in the history
  • Loading branch information
aleuffre authored and toita86 committed Oct 23, 2024
1 parent 40491a3 commit 4dde48e
Showing 1 changed file with 84 additions and 76 deletions.
160 changes: 84 additions & 76 deletions commission/reports/report_settlement_templates.xml
Original file line number Diff line number Diff line change
@@ -1,85 +1,93 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template id="report_settlement_document">
<t t-set="o" t-value="o.with_context(lang=o.agent_id.lang)" />
<t t-call="web.external_layout">
<div class="row">
<div class="offset-col-6 col-6" name="address">
<t t-set="address">
<address
class="mb-0"
t-field="o.agent_id"
t-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": True}'
/>
</t>
</div>
</div>
<div class="mt-5">
<div class="page">
<h2>Settlement</h2>
<div id="informations" class="row mt-4 mb-4">
<div class="col-auto col-3 mw-100 mb-2" t-if="o.date_from">
<strong>From:</strong>
<p t-field="o.date_from" />
</div>
<div class="col-auto col-3 mw-100 mb-2" t-if="o.date_to">
<strong>To:</strong>
<p t-field="o.date_to" />
</div>
</div>
<table class="table table-sm" name="invoice_line_table">
<thead>
<tr>
<th class="text-start">Date</th>
<th class="text-start">Commission</th>
<th class="text-end">Amount settled</th>
</tr>
</thead>
<tbody>
<tr t-foreach="o.line_ids" t-as="l">
<td>
<span t-field="l.date" />
</td>
<td class="text-start">
<span t-field="l.commission_id" />
</td>
<td class="text-end">
<span
t-field="l.settled_amount"
t-options="{'widget': 'monetary', 'display_currency': o.currency_id}"
/>
</td>
</tr>
</tbody>
<tfoot>
<tr>
<td />
<td class="text-end">
<strong>Total</strong>
</td>
<td class="text-end">
<span
t-field="o.total"
t-options="{'widget': 'monetary', 'display_currency': o.currency_id}"
/>
</td>
</tr>
</tfoot>
</table>
</div>
</div>
</t>
</template>

<template id="report_settlement">
<t t-call="web.html_container">
<t
t-set="show_doc_total"
t-value="len(docs) > 1 and len(docs.mapped('currency_id')) == 1"
/>
<t t-foreach="docs" t-as="o">
<t
t-call="commission.report_settlement_document"
t-lang="o.agent_id.lang"
/>
<t t-call="web.internal_layout">
<div class="page">
<t t-if="show_doc_total">
<div class="text-right">
<strong>Global commission amount:</strong>
<span
t-esc="sum(docs.mapped('total'))"
t-options="{'widget': 'monetary', 'display_currency': docs[0].currency_id}"
/>
</div>
</t>
<div class="row mt32 mb32">
<div class="col-auto col-3 mw-100 mb-2" t-if="o.agent_id">
<strong>Agent:</strong>
<p t-field="o.agent_id" />
</div>
<div class="col-auto col-3 mw-100 mb-2" t-if="o.date_from">
<strong>From:</strong>
<p t-field="o.date_from" />
</div>
<div class="col-auto col-3 mw-100 mb-2" t-if="o.date_to">
<strong>To:</strong>
<p t-field="o.date_to" />
</div>
</div>
<table class="table table-sm">
<thead>
<tr>
<th>Invoice date</th>
<th>Invoice</th>
<th>Invoice line</th>
<th>Commission</th>
<th class="text-right">Amount settled</th>
</tr>
</thead>
<tbody>
<tr t-foreach="o.line_ids" t-as="l">
<td>
<span t-field="l.date" />
</td>
<td>
<span t-field="l.settlement_id.invoice_id" />
</td>
<td>
<span t-field="l.invoice_line_id" />
</td>
<td>
<span t-field="l.commission_id" />
</td>
<td class="text-right">
<span
t-field="l.settled_amount"
t-options="{'widget': 'monetary', 'display_currency': o.currency_id}"
/>
</td>
</tr>
</tbody>
</table>
<div class="clearfix" name="commission_total_summary">
<div id="total" class="row" name="total">
<div class="col-6 ml-auto">
<table class="table table-sm">
<tr class="border-black o_total">
<td name="td_amount_total_label"><strong
>Total</strong> (<span
t-field="o.date_from"
/> - <span t-field="o.date_to" />)</td>
<td class="text-right">
<span
t-field="o.total"
t-options="{'widget': 'monetary', 'display_currency': o.currency_id}"
/>
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</t>
</t>
</t>
</template>

</odoo>

0 comments on commit 4dde48e

Please sign in to comment.