From 400659caf894b4b558a6b98bdd41b22edb6ae087 Mon Sep 17 00:00:00 2001 From: AjmalCybro Date: Mon, 11 Dec 2023 16:45:04 +0530 Subject: [PATCH] Dec 8 : [FIX] Bug Fixed 'dynamic_accounts_report' --- dynamic_accounts_report/__manifest__.py | 2 +- dynamic_accounts_report/doc/RELEASE_NOTES.md | 5 +++ .../wizard/general_ledger.py | 34 ++++++++++++------- 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/dynamic_accounts_report/__manifest__.py b/dynamic_accounts_report/__manifest__.py index f731d2e23..3296c94b2 100644 --- a/dynamic_accounts_report/__manifest__.py +++ b/dynamic_accounts_report/__manifest__.py @@ -22,7 +22,7 @@ { 'name': 'Dynamic Financial Reports V16', - 'version': '16.0.1.0.9', + 'version': '16.0.1.0.10', 'category': 'Accounting', 'live_test_url': 'https://www.youtube.com/watch?v=gVQi9q9Rs-E&t=5s', 'summary': """Dynamic Financial Reports with drill diff --git a/dynamic_accounts_report/doc/RELEASE_NOTES.md b/dynamic_accounts_report/doc/RELEASE_NOTES.md index fdb0359d0..a82714360 100644 --- a/dynamic_accounts_report/doc/RELEASE_NOTES.md +++ b/dynamic_accounts_report/doc/RELEASE_NOTES.md @@ -34,4 +34,9 @@ ### 20.11.2023 ### version 16.0.1.0.9, ### BUGFIX +- Profit And Loss: multiple lines of the same account in the financial reports. + +### 11.12.2023 +### version 16.0.1.0.10, +### BUGFIX - Profit And Loss: multiple lines of the same account in the financial reports. \ No newline at end of file diff --git a/dynamic_accounts_report/wizard/general_ledger.py b/dynamic_accounts_report/wizard/general_ledger.py index 457dc29d5..8b5ae4e6d 100644 --- a/dynamic_accounts_report/wizard/general_ledger.py +++ b/dynamic_accounts_report/wizard/general_ledger.py @@ -113,20 +113,26 @@ class GeneralView(models.TransientModel): for item in records['Accounts']: if isinstance(item['name'], dict): item['new_name'] = item['name'][ - user_language] if user_language in item['name'] else \ - item['name']['en_US'] + user_language] if user_language in item['name'] else \ + item['name']['en_US'] else: - item['new_name']=item['name'] - # if user_language in item['name']: - # item['new_name'] = item['name'][user_language] - # else: - # item['new_name'] = item['name'][default_lg] + item['new_name'] = item['name'] + merged_data = {} + for line in records['Accounts']: + account_id = line['account_id'] + if account_id not in merged_data: + merged_data[account_id] = line + else: + merged_data[account_id]['debit'] += line['debit'] + merged_data[account_id]['credit'] += line['credit'] + merged_data[account_id]['balance'] += line['balance'] + report_list = list(merged_data.values()) return { 'name': title, 'type': 'ir.actions.client', 'tag': 'g_l', 'filters': filters, - 'report_lines': records['Accounts'], + 'report_lines': report_list, 'debit_total': records['debit_total'], 'credit_total': records['credit_total'], 'debit_balance': records['debit_balance'], @@ -256,7 +262,8 @@ class GeneralView(models.TransientModel): rec['name'] = localized_name else: # If the translation for the current language is not available, use a default language or handle it as needed. - rec['name'] = rec['name'].get(default_lg, '') # Replace 'en_US' with your desired default language. + rec['name'] = rec['name'].get(default_lg, + '') # Replace 'en_US' with your desired default language. else: # Handle the case where 'name' is not present in the dictionary. rec['name'] = '' # You can use an @@ -312,7 +319,7 @@ class GeneralView(models.TransientModel): # Account Tag filter if vals.get('account_tag_ids'): vals.update({'account_tag_ids': [(6, 0, - vals.get('account_tag_ids'))]}) + vals.get('account_tag_ids'))]}) if vals.get('account_tag_ids') == []: vals.update({'account_tag_ids': [(5,)]}) # Analytic filter @@ -421,9 +428,10 @@ class GeneralView(models.TransientModel): WHERE += ' AND an.id IN %s' % str( tuple(data.get('analytics').ids) + tuple([0])) if data.get('account_tags'): - WHERE += ' AND act.id IN %s' % str(tuple(data.get('account_tags').ids)+ tuple([0])) + WHERE += ' AND act.id IN %s' % str( + tuple(data.get('account_tags').ids) + tuple([0])) - # Get move lines base on sql query and Calculate the total balance + # Get move lines base on sql query and Calculate the total balance # of move lines sql = ('''SELECT l.account_id AS account_id, a.code AS code, a.id AS id, a.name AS name, @@ -446,7 +454,7 @@ class GeneralView(models.TransientModel): AS keys) anl ON true LEFT JOIN account_analytic_account an ON (anl.keys = an.id)''' - + WHERE + new_final_filter + ''' GROUP BY l.account_id, + + WHERE + new_final_filter + ''' GROUP BY l.account_id, a.code,a.id,a.name,anl.keys, act.name''') if data.get('accounts'): params = tuple(where_params)