Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions accounting_pdf_reports/models/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,32 @@ def _query_get(self, domain=None):
where_string, where_params = query.where_clause
tables, where_clause, where_clause_params = from_string, where_string, from_params + where_params
return tables, where_clause, where_clause_params

def format_analytic_distribution(self, distribution):
"""
Format analytic distribution entries, handling both single and compound keys.

Args:
self: Odoo environment
distribution: Dict of analytic distribution (e.g. {'2':90} or {'2,1':90, '3':10})

Returns:
List of formatted strings with analytic account info and percentages
"""
if not distribution:
return []
result = []
for key, percentage in distribution.items():
account_ids = [int(x) for x in key.split(',')]
accounts_info = []

for account_id in account_ids:
account = self.env['account.analytic.account'].browse(account_id)[0]
if account.partner_id:
accounts_info.append(f"{account.name} - {account.partner_id.name}")
else:
accounts_info.append(account.name)

formatted_entry = f"{', '.join(accounts_info)}: {percentage}%"
result.append(formatted_entry)
return result
7 changes: 5 additions & 2 deletions accounting_pdf_reports/report/report_journal_entries.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<th>Date</th>
<th>Partner</th>
<th>Label</th>
<th>Analytic Account</th>
<th>Analytic Distribution</th>
<th>Debit</th>
<th>Credit</th>
</tr>
Expand All @@ -68,7 +68,10 @@
<span t-field="line.name"/>
</td>
<td>
<span t-field="line.analytic_account_id.display_name"/>
<div t-foreach="line.format_analytic_distribution(line.analytic_distribution)" t-as="entry">
<t t-esc="entry"/>
<br/>
</div>
</td>
<td class="text-end">
<span t-field="line.debit"
Expand Down