From 3d05074af520b2103cd07182665c4f72c6bc41da Mon Sep 17 00:00:00 2001 From: Ernad Husremovic Date: Mon, 9 Feb 2026 09:44:07 +0100 Subject: [PATCH] Custom PDF filename with partner names, localize report headers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- .../accounting_pdf_reports/__init__.py | 1 + .../accounting_pdf_reports/__manifest__.py | 2 +- .../controllers/__init__.py | 3 ++ .../controllers/main.py | 29 ++++++++++++++++++ .../report/report_partner_ledger.xml | 30 +++++++++---------- .../wizard/account_partner_ledger.py | 9 ++++-- 6 files changed, 56 insertions(+), 18 deletions(-) create mode 100644 odoo-bringout-odoomates-accounting_pdf_reports/accounting_pdf_reports/controllers/__init__.py create mode 100644 odoo-bringout-odoomates-accounting_pdf_reports/accounting_pdf_reports/controllers/main.py diff --git a/odoo-bringout-odoomates-accounting_pdf_reports/accounting_pdf_reports/__init__.py b/odoo-bringout-odoomates-accounting_pdf_reports/accounting_pdf_reports/__init__.py index ceea55a..7f6af0e 100644 --- a/odoo-bringout-odoomates-accounting_pdf_reports/accounting_pdf_reports/__init__.py +++ b/odoo-bringout-odoomates-accounting_pdf_reports/accounting_pdf_reports/__init__.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- +from . import controllers from . import wizard from . import models from . import report diff --git a/odoo-bringout-odoomates-accounting_pdf_reports/accounting_pdf_reports/__manifest__.py b/odoo-bringout-odoomates-accounting_pdf_reports/accounting_pdf_reports/__manifest__.py index 226bd1f..ba9d4e0 100644 --- a/odoo-bringout-odoomates-accounting_pdf_reports/accounting_pdf_reports/__manifest__.py +++ b/odoo-bringout-odoomates-accounting_pdf_reports/accounting_pdf_reports/__manifest__.py @@ -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', diff --git a/odoo-bringout-odoomates-accounting_pdf_reports/accounting_pdf_reports/controllers/__init__.py b/odoo-bringout-odoomates-accounting_pdf_reports/accounting_pdf_reports/controllers/__init__.py new file mode 100644 index 0000000..65a8c12 --- /dev/null +++ b/odoo-bringout-odoomates-accounting_pdf_reports/accounting_pdf_reports/controllers/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import main diff --git a/odoo-bringout-odoomates-accounting_pdf_reports/accounting_pdf_reports/controllers/main.py b/odoo-bringout-odoomates-accounting_pdf_reports/accounting_pdf_reports/controllers/main.py new file mode 100644 index 0000000..7a2f323 --- /dev/null +++ b/odoo-bringout-odoomates-accounting_pdf_reports/accounting_pdf_reports/controllers/main.py @@ -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 diff --git a/odoo-bringout-odoomates-accounting_pdf_reports/accounting_pdf_reports/report/report_partner_ledger.xml b/odoo-bringout-odoomates-accounting_pdf_reports/accounting_pdf_reports/report/report_partner_ledger.xml index 042dd21..5feec01 100644 --- a/odoo-bringout-odoomates-accounting_pdf_reports/accounting_pdf_reports/report/report_partner_ledger.xml +++ b/odoo-bringout-odoomates-accounting_pdf_reports/accounting_pdf_reports/report/report_partner_ledger.xml @@ -15,27 +15,27 @@ text-align: right; } -

Partner Ledger

+

Kartica partnera

- Company: + Tvrtka:

- Date from : + Datum od:
- Date to : + Datum do:
- Target Moves: -

All Entries

-

All Posted Entries

+ Transakcije: +

Sve proknjižene stavke

+

Samo proknjižene stavke

@@ -43,14 +43,14 @@ - - - - - - - - + + + + + + + + diff --git a/odoo-bringout-odoomates-accounting_pdf_reports/accounting_pdf_reports/wizard/account_partner_ledger.py b/odoo-bringout-odoomates-accounting_pdf_reports/accounting_pdf_reports/wizard/account_partner_ledger.py index 4e15e61..5fb2e61 100644 --- a/odoo-bringout-odoomates-accounting_pdf_reports/accounting_pdf_reports/wizard/account_partner_ledger.py +++ b/odoo-bringout-odoomates-accounting_pdf_reports/accounting_pdf_reports/wizard/account_partner_ledger.py @@ -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)
DateJRNLAccountRefDebit ()Credit ()Balance ()CurrencyDatumŽURNNaziv kontaOpisDuguje ()Potražuje ()Saldo ()Valuta