From 48d0c9a9d6bc46efb011d4465ec93a5ad91afd9d Mon Sep 17 00:00:00 2001 From: Risvana Cybro Date: Wed, 22 Oct 2025 21:47:06 +0530 Subject: [PATCH] Oct 22: [FIX] Bug fixed 'dynamic_accounts_report' --- dynamic_accounts_report/__manifest__.py | 2 +- dynamic_accounts_report/doc/RELEASE_NOTES.md | 6 ++- .../models/account_trial_balance.py | 2 +- .../report/trial_balance.xml | 2 +- .../static/src/js/trial_balance.js | 41 ++++++++++++++----- .../static/src/xml/trial_balance_view.xml | 4 ++ 6 files changed, 42 insertions(+), 15 deletions(-) diff --git a/dynamic_accounts_report/__manifest__.py b/dynamic_accounts_report/__manifest__.py index ffb80ddea..d3de9fa9b 100644 --- a/dynamic_accounts_report/__manifest__.py +++ b/dynamic_accounts_report/__manifest__.py @@ -21,7 +21,7 @@ ################################################################################ { 'name': 'Odoo18 Dynamic Accounting Reports', - 'version': '18.0.1.2.4', + 'version': '18.0.1.2.5', 'category': 'Accounting', 'summary': "Odoo 18 Accounting Financial Reports,Dynamic Accounting Reports, Dynamic Financial Reports,Dynamic Report Odoo18, Odoo18,Financial Reports, Odoo18 Accounting,Accounting, Odoo Apps", 'description': "This module creates dynamic Accounting General Ledger, Trial" diff --git a/dynamic_accounts_report/doc/RELEASE_NOTES.md b/dynamic_accounts_report/doc/RELEASE_NOTES.md index 8d013e80d..d9a5515f6 100644 --- a/dynamic_accounts_report/doc/RELEASE_NOTES.md +++ b/dynamic_accounts_report/doc/RELEASE_NOTES.md @@ -24,4 +24,8 @@ #### Version 18.0.1.2.4 #### UPDT - Bug Fixing in the accounting report (Trial Balance). -- \ No newline at end of file + +#### 15.10.2025 +#### Version 18.0.1.2.5 +#### UPDT +- Bug Fixing in the accounting report (Trial Balance). diff --git a/dynamic_accounts_report/models/account_trial_balance.py b/dynamic_accounts_report/models/account_trial_balance.py index 3d765089e..cae5a2c49 100644 --- a/dynamic_accounts_report/models/account_trial_balance.py +++ b/dynamic_accounts_report/models/account_trial_balance.py @@ -421,7 +421,7 @@ class AccountTrialBalance(models.TransientModel): if data: if report_action == 'dynamic_accounts_report.action_trial_balance': row = 11 - for move_line in data['data'][0]: + for move_line in data['data']: sheet.write(row, col, move_line['account'], side_heading_sub) sheet.write(row, col + 1, move_line['initial_total_debit'], diff --git a/dynamic_accounts_report/report/trial_balance.xml b/dynamic_accounts_report/report/trial_balance.xml index f59c6a136..b363fd013 100644 --- a/dynamic_accounts_report/report/trial_balance.xml +++ b/dynamic_accounts_report/report/trial_balance.xml @@ -112,7 +112,7 @@ - diff --git a/dynamic_accounts_report/static/src/js/trial_balance.js b/dynamic_accounts_report/static/src/js/trial_balance.js index 28942c8ca..fd32990dd 100644 --- a/dynamic_accounts_report/static/src/js/trial_balance.js +++ b/dynamic_accounts_report/static/src/js/trial_balance.js @@ -11,7 +11,6 @@ let monthNamesShort = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", " class TrialBalance extends owl.Component { async setup() { - super.setup(...arguments); this.initial_render = true; this.orm = useService('orm'); this.action = useService('action'); @@ -44,7 +43,6 @@ class TrialBalance extends owl.Component { }, }); this.load_data(self.initial_render = true); - } async load_data() { /** @@ -341,6 +339,27 @@ class TrialBalance extends owl.Component { getDomain() { return []; } + + normalizeReportData(rawData) { + // 1️⃣ If rawData is nested (like [[{...}, {...}], {...}]), flatten it + let accounts = Array.isArray(rawData) && Array.isArray(rawData[0]) + ? rawData[0] // extract the inner array + : rawData; + + // 2️⃣ Ensure numeric fields are actual numbers, not strings + accounts = accounts.map(acc => ({ + ...acc, + initial_total_debit: Number(acc.initial_total_debit) || 0, + initial_total_credit: Number(acc.initial_total_credit) || 0, + total_debit: Number(acc.total_debit) || 0, + total_credit: Number(acc.total_credit) || 0, + end_total_debit: Number(acc.end_total_debit) || 0, + end_total_credit: Number(acc.end_total_credit) || 0 + })); + + return accounts; + } + async printPdf(ev) { /** * Asynchronously generates and prints a PDF report. @@ -366,7 +385,7 @@ class TrialBalance extends owl.Component { 'report_name': 'dynamic_accounts_report.trial_balance', 'report_file': 'dynamic_accounts_report.trial_balance', 'data': { - 'data': self.state.data, + 'data': this.normalizeReportData(self.state.data), 'date_viewed': data_viewed, 'filters': this.filter(), 'apply_comparison': self.state.apply_comparison, @@ -381,25 +400,25 @@ class TrialBalance extends owl.Component { var self=this; let startDate, endDate; let startYear, startMonth, startDay, endYear, endMonth, endDay; - if (self.state.date_range){ + if (self.state.date_type){ const today = new Date(); - if (self.state.date_range === 'year') { + if (self.state.date_type === 'year') { startDate = new Date(today.getFullYear(), 0, 1); endDate = new Date(today.getFullYear(), 11, 31); - } else if (self.state.date_range === 'quarter') { + } else if (self.state.date_type === 'quarter') { const currentQuarter = Math.floor(today.getMonth() / 3); startDate = new Date(today.getFullYear(), currentQuarter * 3, 1); endDate = new Date(today.getFullYear(), (currentQuarter + 1) * 3, 0); - } else if (self.state.date_range === 'month') { + } else if (self.state.date_type === 'month') { startDate = new Date(today.getFullYear(), today.getMonth(), 1); endDate = new Date(today.getFullYear(), today.getMonth() + 1, 0); - } else if (self.state.date_range === 'last-month') { + } else if (self.state.date_type === 'last-month') { startDate = new Date(today.getFullYear(), today.getMonth() - 1, 1); endDate = new Date(today.getFullYear(), today.getMonth(), 0); - } else if (self.state.date_range === 'last-year') { + } else if (self.state.date_type === 'last-year') { startDate = new Date(today.getFullYear() - 1, 0, 1); endDate = new Date(today.getFullYear() - 1, 11, 31); - } else if (self.state.date_range === 'last-quarter') { + } else if (self.state.date_type === 'last-quarter') { const lastQuarter = Math.floor((today.getMonth() - 3) / 3); startDate = new Date(today.getFullYear(), lastQuarter * 3, 1); endDate = new Date(today.getFullYear(), (lastQuarter + 1) * 3, 0); @@ -450,7 +469,7 @@ class TrialBalance extends owl.Component { var self = this; var action_title = self.props.action.display_name; var datas = { - 'data': self.state.data, + 'data': this.normalizeReportData(self.state.data), 'date_viewed': self.state.date_viewed, 'filters': this.filter(), 'apply_comparison': self.state.apply_comparison, diff --git a/dynamic_accounts_report/static/src/xml/trial_balance_view.xml b/dynamic_accounts_report/static/src/xml/trial_balance_view.xml index ad738771b..78384a4df 100644 --- a/dynamic_accounts_report/static/src/xml/trial_balance_view.xml +++ b/dynamic_accounts_report/static/src/xml/trial_balance_view.xml @@ -343,6 +343,10 @@ + + +