Custom PDF filename with partner names, localize report headers

- Override report controller to set filename from wizard context
  (print_report_name not evaluated for wizard-based reports)
- Wizard passes report_filename via context: "Kartica partnera Paper Star d.o.o"
- Localize all PDF headers to Bosnian: Datum, ŽURN, Naziv konta,
  Opis, Duguje (KM), Potražuje (KM), Saldo (KM)

🤖 assisted by claude
This commit is contained in:
Ernad Husremovic 2026-02-09 09:44:07 +01:00
parent 889cc6a278
commit 3d05074af5
6 changed files with 56 additions and 18 deletions

View file

@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from . import controllers
from . import wizard
from . import models
from . import report

View file

@ -2,7 +2,7 @@
{
'name': 'Odoo 16 Accounting Financial Reports',
'version': '16.0.2.0.8',
'version': '16.0.2.0.9',
'category': 'Invoicing Management',
'description': 'Accounting Reports For Odoo 16, Accounting Financial Reports, '
'Odoo 16 Financial Reports',

View file

@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import main

View file

@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
import json
from odoo.http import content_disposition, request, route
from odoo.addons.web.controllers.report import ReportController
class CustomReportController(ReportController):
@route()
def report_download(self, data, context=None, token=None):
response = super().report_download(data, context=context, token=token)
try:
requestcontent = json.loads(data)
url = requestcontent[0]
if 'report_partnerledger' in url and context:
ctx = json.loads(context)
report_filename = ctx.get('report_filename')
if report_filename:
response.headers['Content-Disposition'] = content_disposition(
report_filename + '.pdf'
)
except Exception:
pass
return response

View file

@ -15,27 +15,27 @@
text-align: right;
}
</style>
<h2>Partner Ledger</h2>
<h2>Kartica partnera</h2>
<div class="row">
<div class="col-3">
<strong>Company:</strong>
<strong>Tvrtka:</strong>
<p t-esc="res_company.name"/>
</div>
<div class="col-3">
<t t-if="data['form']['date_from']">
<strong>Date from :</strong>
<strong>Datum od:</strong>
<span t-esc="data['form']['date_from']" t-options="{'widget': 'date'}"/>
<br/>
</t>
<t t-if="data['form']['date_to']">
<strong>Date to :</strong>
<strong>Datum do:</strong>
<span t-esc="data['form']['date_to']" t-options="{'widget': 'date'}"/>
</t>
</div>
<div class="col-3">
<strong>Target Moves:</strong>
<p t-if="data['form']['target_move'] == 'all'">All Entries</p>
<p t-if="data['form']['target_move'] == 'posted'">All Posted Entries</p>
<strong>Transakcije:</strong>
<p t-if="data['form']['target_move'] == 'all'">Sve proknjižene stavke</p>
<p t-if="data['form']['target_move'] == 'posted'">Samo proknjižene stavke</p>
</div>
</div>
@ -43,14 +43,14 @@
<table class="table table-sm table-reports">
<thead>
<tr>
<th>Date</th>
<th>JRNL</th>
<th>Account</th>
<th>Ref</th>
<th class="col-amount">Debit (<t t-esc="currency_symbol"/>)</th>
<th class="col-amount">Credit (<t t-esc="currency_symbol"/>)</th>
<th class="col-amount">Balance (<t t-esc="currency_symbol"/>)</th>
<th class="col-amount" t-if="data['form']['amount_currency']">Currency</th>
<th>Datum</th>
<th>ŽURN</th>
<th>Naziv konta</th>
<th>Opis</th>
<th class="col-amount">Duguje (<t t-esc="currency_symbol"/>)</th>
<th class="col-amount">Potražuje (<t t-esc="currency_symbol"/>)</th>
<th class="col-amount">Saldo (<t t-esc="currency_symbol"/>)</th>
<th class="col-amount" t-if="data['form']['amount_currency']">Valuta</th>
</tr>
</thead>
<t t-foreach="docs" t-as="o">

View file

@ -22,5 +22,10 @@ class AccountPartnerLedger(models.TransientModel):
def _print_report(self, data):
data = self._get_report_data(data)
return self.env.ref('accounting_pdf_reports.action_report_partnerledger').with_context(landscape=True).\
report_action(self, data=data)
if self.partner_ids:
report_filename = _('Kartica partnera') + ' ' + ', '.join(self.partner_ids.mapped('name'))
else:
report_filename = _('Kartica partnera')
return self.env.ref(
'accounting_pdf_reports.action_report_partnerledger'
).with_context(landscape=True, report_filename=report_filename).report_action(self, data=data)