From 1232656ad0bc4a87a46036116e8b113b7c576695 Mon Sep 17 00:00:00 2001 From: RisvanaCybro Date: Wed, 19 Jun 2024 11:57:46 +0530 Subject: [PATCH] Jun 19: [FIX] Bug Fixed 'dynamic_accounts_report' --- dynamic_accounts_report/controllers/controllers.py | 6 ++++-- dynamic_accounts_report/models/account_general_ledger.py | 4 ++-- dynamic_accounts_report/models/account_partner_ledger.py | 4 ++-- dynamic_accounts_report/models/account_trial_balance.py | 4 ++-- dynamic_accounts_report/models/aged_payable_report.py | 4 ++-- dynamic_accounts_report/models/aged_receivable_report.py | 4 ++-- dynamic_accounts_report/models/bank_book_report.py | 4 ++-- dynamic_accounts_report/models/cash_book_report.py | 4 ++-- .../models/dynamic_balance_sheet_report.py | 4 ++-- dynamic_accounts_report/models/tax_report.py | 2 +- .../static/src/js/aged_payable_report.js | 1 + .../static/src/js/aged_receivable_report.js | 1 + dynamic_accounts_report/static/src/js/balance_sheet.js | 1 + dynamic_accounts_report/static/src/js/bank_flow.js | 1 + dynamic_accounts_report/static/src/js/cash_flow.js | 1 + dynamic_accounts_report/static/src/js/general_ledger.js | 1 + dynamic_accounts_report/static/src/js/partner_ledger.js | 2 ++ dynamic_accounts_report/static/src/js/profit_and_loss.js | 1 + dynamic_accounts_report/static/src/js/tax_report.js | 1 + dynamic_accounts_report/static/src/js/trial_balance.js | 1 + 20 files changed, 32 insertions(+), 19 deletions(-) diff --git a/dynamic_accounts_report/controllers/controllers.py b/dynamic_accounts_report/controllers/controllers.py index 97d173e5f..48a3588cb 100644 --- a/dynamic_accounts_report/controllers/controllers.py +++ b/dynamic_accounts_report/controllers/controllers.py @@ -28,7 +28,8 @@ from odoo.tools import html_escape class XLSXReportController(http.Controller): @http.route('/xlsx_report', type='http', auth='user', methods=['POST'], csrf=False) - def get_report_xlsx(self, model, data, output_format, report_name): + def get_report_xlsx(self, model, data, output_format, report_name, + report_action): """Generate an XLSX report based on the provided data and return it as a response. Args: @@ -56,7 +57,8 @@ class XLSXReportController(http.Controller): content_disposition(report_name + '.xlsx')) ] ) - report_obj.get_xlsx_report(data, response, report_name) + report_obj.get_xlsx_report(data, response, report_name, + report_action) response.set_cookie('fileToken', token) return response except Exception as e: diff --git a/dynamic_accounts_report/models/account_general_ledger.py b/dynamic_accounts_report/models/account_general_ledger.py index 42da3c271..ae8bfa991 100644 --- a/dynamic_accounts_report/models/account_general_ledger.py +++ b/dynamic_accounts_report/models/account_general_ledger.py @@ -198,7 +198,7 @@ class AccountGeneralLedger(models.TransientModel): return account_dict @api.model - def get_xlsx_report(self, data, response, report_name): + def get_xlsx_report(self, data, response, report_name, report_action): """ Generate an XLSX report based on the provided data and write it to the response stream. @@ -267,7 +267,7 @@ class AccountGeneralLedger(models.TransientModel): option_keys_str = ', '.join(option_keys) sheet.merge_range('C6:G6', option_keys_str, filter_body) if data: - if report_name == 'General Ledger': + if report_action == 'dynamic_accounts_report.action_general_ledger': sheet.write(8, col, ' ', sub_heading) sheet.write(8, col + 1, 'Date', sub_heading) sheet.merge_range('C9:E9', 'Communication', sub_heading) diff --git a/dynamic_accounts_report/models/account_partner_ledger.py b/dynamic_accounts_report/models/account_partner_ledger.py index b8859889f..3cffdaec3 100644 --- a/dynamic_accounts_report/models/account_partner_ledger.py +++ b/dynamic_accounts_report/models/account_partner_ledger.py @@ -237,7 +237,7 @@ class AccountPartnerLedger(models.TransientModel): return partner_dict @api.model - def get_xlsx_report(self, data, response, report_name): + def get_xlsx_report(self, data, response, report_name, report_action): """ Generate an Excel report based on the provided data. @@ -306,7 +306,7 @@ class AccountPartnerLedger(models.TransientModel): option_keys_str = ', '.join(option_keys) sheet.merge_range('C6:G6', option_keys_str, filter_body) if data: - if report_name == 'Partner Ledger': + if report_action == 'dynamic_accounts_report.action_partner_ledger': sheet.write(8, col, ' ', sub_heading) sheet.write(8, col + 1, 'JNRL', sub_heading) sheet.write(8, col + 2, 'Account', sub_heading) diff --git a/dynamic_accounts_report/models/account_trial_balance.py b/dynamic_accounts_report/models/account_trial_balance.py index 92089b984..549474f03 100644 --- a/dynamic_accounts_report/models/account_trial_balance.py +++ b/dynamic_accounts_report/models/account_trial_balance.py @@ -325,7 +325,7 @@ class AccountTrialBalance(models.TransientModel): return month_names[date.month] @api.model - def get_xlsx_report(self, data, response, report_name): + def get_xlsx_report(self, data, response, report_name, report_action): """ Generate an XLSX report based on provided data and response stream. Generates an Excel workbook with specified report format, including @@ -416,7 +416,7 @@ class AccountTrialBalance(models.TransientModel): sheet.write(10, col + i, 'Debit', sub_heading) sheet.write(10, col + (i + 1), 'Credit', sub_heading) if data: - if report_name == 'Trial Balance': + if report_action == 'dynamic_accounts_report.action_trial_balance': row = 11 for move_line in data['data']: sheet.write(row, col, move_line['account'], diff --git a/dynamic_accounts_report/models/aged_payable_report.py b/dynamic_accounts_report/models/aged_payable_report.py index 0fc2f2a4e..405a91d7f 100644 --- a/dynamic_accounts_report/models/aged_payable_report.py +++ b/dynamic_accounts_report/models/aged_payable_report.py @@ -153,7 +153,7 @@ class AgePayableReport(models.TransientModel): return move_line_list @api.model - def get_xlsx_report(self, data, response, report_name): + def get_xlsx_report(self, data, response, report_name, report_action): """ Generate an Excel report based on the provided data. :param data: The data used to generate the report. @@ -205,7 +205,7 @@ class AgePayableReport(models.TransientModel): display_names_str = ', '.join(display_names) sheet.merge_range('C4:G4', display_names_str, filter_body) if data: - if report_name == 'Aged Payable': + if report_action == 'dynamic_accounts_report.action_aged_payable': sheet.write(6, col, ' ', sub_heading) sheet.write(6, col + 1, 'Invoice Date', sub_heading) sheet.write(6, col + 2, 'Amount Currency', sub_heading) diff --git a/dynamic_accounts_report/models/aged_receivable_report.py b/dynamic_accounts_report/models/aged_receivable_report.py index f4d8f6606..7385019a6 100644 --- a/dynamic_accounts_report/models/aged_receivable_report.py +++ b/dynamic_accounts_report/models/aged_receivable_report.py @@ -163,7 +163,7 @@ class AgeReceivableReport(models.TransientModel): return move_line_list @api.model - def get_xlsx_report(self, data, response, report_name): + def get_xlsx_report(self, data, response, report_name, report_action): """ Generate an Excel report based on the provided data. @@ -219,7 +219,7 @@ class AgeReceivableReport(models.TransientModel): display_names_str = ', '.join(display_names) sheet.merge_range('C4:G4', display_names_str, filter_body) if data: - if report_name == 'Aged Receivable': + if report_action == 'dynamic_accounts_report.action_aged_receivable': sheet.write(6, col, ' ', sub_heading) sheet.write(6, col + 1, 'Invoice Date', sub_heading) sheet.write(6, col + 2, 'Amount Currency', sub_heading) diff --git a/dynamic_accounts_report/models/bank_book_report.py b/dynamic_accounts_report/models/bank_book_report.py index f9c9a9188..4710e9ace 100644 --- a/dynamic_accounts_report/models/bank_book_report.py +++ b/dynamic_accounts_report/models/bank_book_report.py @@ -179,7 +179,7 @@ class BankBookReport(models.TransientModel): return data @api.model - def get_xlsx_report(self, data, response, report_name): + def get_xlsx_report(self, data, response, report_name, report_action): """ Generate an Excel report based on the provided data. :param data: The data used to generate the report. @@ -243,7 +243,7 @@ class BankBookReport(models.TransientModel): option_keys_str = ', '.join(option_keys) sheet.merge_range('C6:G6', option_keys_str, filter_body) if data: - if report_name == 'Bank Book': + if report_action == 'dynamic_accounts_report.action_bank_book': sheet.write(8, col, ' ', sub_heading) sheet.merge_range('B9:C9', 'Journal', sub_heading) sheet.merge_range('D9:E9', 'Partner', sub_heading) diff --git a/dynamic_accounts_report/models/cash_book_report.py b/dynamic_accounts_report/models/cash_book_report.py index b14761e75..cc09188ad 100644 --- a/dynamic_accounts_report/models/cash_book_report.py +++ b/dynamic_accounts_report/models/cash_book_report.py @@ -203,7 +203,7 @@ class CashBookReport(models.TransientModel): return data @api.model - def get_xlsx_report(self, data, response, report_name): + def get_xlsx_report(self, data, response, report_name, report_action): """ Generate an Excel report based on the provided data. :param data: The data used to generate the report. @@ -267,7 +267,7 @@ class CashBookReport(models.TransientModel): option_keys_str = ', '.join(option_keys) sheet.merge_range('C6:G6', option_keys_str, filter_body) if data: - if report_name == 'Cash Book': + if report_action == 'dynamic_accounts_report.action_cash_book': sheet.write(8, col, ' ', sub_heading) sheet.merge_range('B9:C9', 'Journal', sub_heading) sheet.merge_range('D9:E9', 'Partner', sub_heading) diff --git a/dynamic_accounts_report/models/dynamic_balance_sheet_report.py b/dynamic_accounts_report/models/dynamic_balance_sheet_report.py index d54b9d0bd..f6349d784 100644 --- a/dynamic_accounts_report/models/dynamic_balance_sheet_report.py +++ b/dynamic_accounts_report/models/dynamic_balance_sheet_report.py @@ -448,7 +448,7 @@ class ProfitLossReport(models.TransientModel): return last_year_date_list @api.model - def get_xlsx_report(self, data, response, report_name): + def get_xlsx_report(self, data, response, report_name, report_action): """Generate and return an XLSX report based on the provided data. :param data: The report data in JSON format. :param report_name: Name of the report. @@ -484,7 +484,7 @@ class ProfitLossReport(models.TransientModel): col += 1 col = 0 if data: - if report_name == 'Profit and Loss': + if report_action == 'dynamic_accounts_report.action_dynamic_profit_and_loss': sheet.write(6, col, 'Net Profit', sub_heading) for datas in data['datas']: sheet.write(6, col + 1, datas['total'], side_heading_sub) diff --git a/dynamic_accounts_report/models/tax_report.py b/dynamic_accounts_report/models/tax_report.py index 529937b89..a65adf37a 100644 --- a/dynamic_accounts_report/models/tax_report.py +++ b/dynamic_accounts_report/models/tax_report.py @@ -609,7 +609,7 @@ class TaxReport(models.TransientModel): return month_names[date.month] @api.model - def get_xlsx_report(self, data, response, report_name): + def get_xlsx_report(self, data, response, report_name, report_action): """ Generate an XLSX report based on provided data and response stream. diff --git a/dynamic_accounts_report/static/src/js/aged_payable_report.js b/dynamic_accounts_report/static/src/js/aged_payable_report.js index 581c22bd4..2aabb68cb 100644 --- a/dynamic_accounts_report/static/src/js/aged_payable_report.js +++ b/dynamic_accounts_report/static/src/js/aged_payable_report.js @@ -224,6 +224,7 @@ class AgedPayable extends owl.Component { 'model': 'age.payable.report', 'data': JSON.stringify(datas), 'output_format': 'xlsx', + 'report_action': self.props.action.xml_id, 'report_name': action_title, }, }; diff --git a/dynamic_accounts_report/static/src/js/aged_receivable_report.js b/dynamic_accounts_report/static/src/js/aged_receivable_report.js index 2bef2f148..07f8e7e7e 100644 --- a/dynamic_accounts_report/static/src/js/aged_receivable_report.js +++ b/dynamic_accounts_report/static/src/js/aged_receivable_report.js @@ -223,6 +223,7 @@ class AgedReceivable extends owl.Component { 'model': 'age.receivable.report', 'data': JSON.stringify(datas), 'output_format': 'xlsx', + 'report_action': self.props.action.xml_id, 'report_name': action_title, }, }; diff --git a/dynamic_accounts_report/static/src/js/balance_sheet.js b/dynamic_accounts_report/static/src/js/balance_sheet.js index 5e3d5c1db..f9c715bde 100644 --- a/dynamic_accounts_report/static/src/js/balance_sheet.js +++ b/dynamic_accounts_report/static/src/js/balance_sheet.js @@ -99,6 +99,7 @@ class BalanceSheet extends owl.Component { 'data': JSON.stringify(self.state), 'output_format': 'xlsx', 'report_name': self.props.action.display_name, + 'report_action': self.props.action.xml_id, }, }; BlockUI; diff --git a/dynamic_accounts_report/static/src/js/bank_flow.js b/dynamic_accounts_report/static/src/js/bank_flow.js index 8f5c4f1f5..342253f45 100644 --- a/dynamic_accounts_report/static/src/js/bank_flow.js +++ b/dynamic_accounts_report/static/src/js/bank_flow.js @@ -212,6 +212,7 @@ class BankBook extends owl.Component { 'model': 'bank.book.report', 'data': JSON.stringify(datas), 'output_format': 'xlsx', + 'report_action': self.props.action.xml_id, 'report_name': action_title, }, }; diff --git a/dynamic_accounts_report/static/src/js/cash_flow.js b/dynamic_accounts_report/static/src/js/cash_flow.js index 258127fbb..5064af385 100644 --- a/dynamic_accounts_report/static/src/js/cash_flow.js +++ b/dynamic_accounts_report/static/src/js/cash_flow.js @@ -205,6 +205,7 @@ class CashBook extends owl.Component { 'model': 'cash.book.report', 'data': JSON.stringify(datas), 'output_format': 'xlsx', + 'report_action': self.props.action.xml_id, 'report_name': action_title, }, }; diff --git a/dynamic_accounts_report/static/src/js/general_ledger.js b/dynamic_accounts_report/static/src/js/general_ledger.js index 8b48454d0..eabd63955 100644 --- a/dynamic_accounts_report/static/src/js/general_ledger.js +++ b/dynamic_accounts_report/static/src/js/general_ledger.js @@ -129,6 +129,7 @@ class GeneralLedger extends owl.Component { 'model': 'account.general.ledger', 'data': JSON.stringify(datas), 'output_format': 'xlsx', + 'report_action': self.props.action.xml_id, 'report_name': action_title, }, }; diff --git a/dynamic_accounts_report/static/src/js/partner_ledger.js b/dynamic_accounts_report/static/src/js/partner_ledger.js index 1253ed8be..ae488db3b 100644 --- a/dynamic_accounts_report/static/src/js/partner_ledger.js +++ b/dynamic_accounts_report/static/src/js/partner_ledger.js @@ -171,6 +171,7 @@ class PartnerLedger extends owl.Component { * Generates and downloads an XLSX report for the partner ledger. */ var self = this; + let partner_list = [] let partner_value = [] let partner_totals = '' @@ -193,6 +194,7 @@ class PartnerLedger extends owl.Component { 'model': 'account.partner.ledger', 'data': JSON.stringify(datas), 'output_format': 'xlsx', + 'report_action': self.props.action.xml_id, 'report_name': action_title, }, }; diff --git a/dynamic_accounts_report/static/src/js/profit_and_loss.js b/dynamic_accounts_report/static/src/js/profit_and_loss.js index 0c6a03e6d..a0a9618b6 100644 --- a/dynamic_accounts_report/static/src/js/profit_and_loss.js +++ b/dynamic_accounts_report/static/src/js/profit_and_loss.js @@ -87,6 +87,7 @@ class ProfitAndLoss extends owl.Component { 'model': 'dynamic.balance.sheet.report', 'data': JSON.stringify(self.state), 'output_format': 'xlsx', + 'report_action': self.props.action.xml_id, 'report_name': self.props.action.display_name, }, }; diff --git a/dynamic_accounts_report/static/src/js/tax_report.js b/dynamic_accounts_report/static/src/js/tax_report.js index 39c712d79..6093a4f52 100644 --- a/dynamic_accounts_report/static/src/js/tax_report.js +++ b/dynamic_accounts_report/static/src/js/tax_report.js @@ -335,6 +335,7 @@ class TaxReport extends owl.Component { 'model': 'tax.report', 'data': JSON.stringify(datas), 'output_format': 'xlsx', + 'report_action': self.props.action.id, 'report_name': action_title, }, }; diff --git a/dynamic_accounts_report/static/src/js/trial_balance.js b/dynamic_accounts_report/static/src/js/trial_balance.js index 1a1c37784..105ad0c35 100644 --- a/dynamic_accounts_report/static/src/js/trial_balance.js +++ b/dynamic_accounts_report/static/src/js/trial_balance.js @@ -467,6 +467,7 @@ class TrialBalance extends owl.Component { 'model': 'account.trial.balance', 'data': JSON.stringify(datas), 'output_format': 'xlsx', + 'report_action': self.props.action.xml_id, 'report_name': action_title, }, };