Skip to content

Commit

Permalink
add feature to show bank account
Browse files Browse the repository at this point in the history
  • Loading branch information
yostashiro committed Jan 29, 2025
1 parent 80f1082 commit c871f86
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 19 deletions.
25 changes: 20 additions & 5 deletions report_alternative_layout/models/ir_actions_report.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright 2024 Quartile
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# Copyright 2024-2025 Quartile (https://www.quartile.co)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models

Expand All @@ -15,15 +15,30 @@ class Report(models.Model):
help="If selected, the commercial partner of the document partner will show "
"in the report output (instead of the document partner)."
)
show_remit_to_bank = fields.Boolean(
"Show Remit-to Bank",
help="If selected, remit-to bank account will show in the report output.",
)

def _render_qweb_pdf(self, report_ref, res_ids=None, data=None):
report = self._get_report(report_ref)
if report.apply_alternative_layout:
self = self.with_context(apply_alternative_layout=True)
return super()._render_qweb_pdf(report_ref, res_ids, data)

def _get_partner(self, xmlid, partner):
report = self._get_report_from_name(xmlid)
if report.show_commercial_partner:
def _get_partner(self, partner):
self.ensure_one()
if self.show_commercial_partner:
return partner.commercial_partner_id
return partner

def _get_remit_to_bank(self, record):
self.ensure_one()
if not self.show_remit_to_bank:
return False
if "company_id" not in record._fields:
return False
company = record.company_id
if not company:
return False
return company.bank_ids[:1]
46 changes: 32 additions & 14 deletions report_alternative_layout/report/report_template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,55 @@
</xpath>
<xpath expr="//t[@t-call='web.address_layout']" position="after">
<t t-else="">
<t
t-set="report"
t-value="o.env['ir.actions.report']._get_report_from_name(xmlid)"
/>
<t t-set="partner" t-value="report._get_partner(o.partner_id)" />
<div class="row" name="address_layout">
<div class="col-7" name="partner_address">
<t
t-set="partner_name"
t-value="o.env['ir.actions.report']._get_partner(xmlid, o.partner_id)"
/>
<div
t-esc="partner_name"
t-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": true}'
t-esc="partner"
t-options='{"widget": "contact", "fields": ["address", "name", "phone"], "no_marker": true}'
/>
<div
name="information_block"
t-if="information_block"
class="mt-3"
>
<t t-out="information_block" />
</div>
</div>
<div class="col-5" name="company_address">
<ul class="list-unstyled">
<li t-if="company.is_company_details_empty"><t
<li t-if="company.is_company_details_empty">
<t
t-esc="company.partner_id"
t-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": true}'
/></li>
/>
</li>
<li t-else=""><t t-esc="company.company_details" /></li>
<li t-if="forced_vat">
<t t-esc="company.country_id.vat_label or 'Tax ID'" />:
<span t-esc="forced_vat" />
</li>
</ul>
<t
t-set="remit_to_bank"
t-value="report._get_remit_to_bank(o)"
/>
<div name="remit_to_bank" t-if="remit_to_bank" class="mt16">
<strong>Remit-to:</strong>
<ul class="list-unstyled">
<li><span t-field="remit_to_bank.bank_id" /></li>
<li><span t-field="remit_to_bank.acc_number" /></li>
<li>
<span t-field="remit_to_bank.acc_holder_name" />
</li>
</ul>
</div>
</div>
</div>
<t t-if="information_block">
<t t-set="colclass" t-value="'col-5 offset-1'" />
<div name="information_block" class="col-6">
<t t-out="information_block" />
</div>
</t>
</t>
</xpath>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<group>
<field name="apply_alternative_layout" />
<field name="show_commercial_partner" />
<field name="show_remit_to_bank" />
</group>
</xpath>
</field>
Expand Down

0 comments on commit c871f86

Please sign in to comment.