diff --git a/dynamic_accounts_report/__manifest__.py b/dynamic_accounts_report/__manifest__.py index 0f5533f9b..96d5aba18 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.7', + 'version': '16.0.1.0.8', '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 570db338b..bb55e2f99 100644 --- a/dynamic_accounts_report/doc/RELEASE_NOTES.md +++ b/dynamic_accounts_report/doc/RELEASE_NOTES.md @@ -25,7 +25,8 @@ #### BUGFIX - Report Bug Fix: The issues with the analytic filter in the general ledger, partner ledger, and profit and loss statement have been fixed, and the problem with language while printing reports has also been addressed. -#### 08.09.2023 +#### 18.09.2023 #### Version 16.0.1.0.7 #### BUGFIX -- Report Bug Fix: Problem with language while printing profit and loss report fixed. \ No newline at end of file +- Report Bug Fix: Problem with language while printing profit and loss report fixed. +- Report Bug Fix: Problem with language while opening cash flow statement. \ No newline at end of file diff --git a/dynamic_accounts_report/report/ageing.py b/dynamic_accounts_report/report/ageing.py index 50af95564..1e95e0237 100644 --- a/dynamic_accounts_report/report/ageing.py +++ b/dynamic_accounts_report/report/ageing.py @@ -27,7 +27,6 @@ class PartnerAgeing(models.AbstractModel): @api.model def _get_report_values(self,docids, data=None): - print(data) if self.env.context.get('ageing_pdf_report'): if data.get('report_data'): data.update( diff --git a/dynamic_accounts_report/report/ageing.xml b/dynamic_accounts_report/report/ageing.xml index ae7084692..f4aa95914 100644 --- a/dynamic_accounts_report/report/ageing.xml +++ b/dynamic_accounts_report/report/ageing.xml @@ -42,8 +42,6 @@ - -

@@ -97,7 +95,8 @@ - + - + @@ -117,17 +117,18 @@ t-value="request.env.context.get('lang')"/> - - - - - - - - - - - - + + + + + + + + + + + + - diff --git a/dynamic_accounts_report/static/src/js/cash_flow.js b/dynamic_accounts_report/static/src/js/cash_flow.js index 5239de13f..bc5eaf974 100644 --- a/dynamic_accounts_report/static/src/js/cash_flow.js +++ b/dynamic_accounts_report/static/src/js/cash_flow.js @@ -9,7 +9,7 @@ odoo.define('dynamic_cash_flow_statements.cash_flow', function(require) { var QWeb = core.qweb; var _t = core._t; var framework = require('web.framework'); - + var session = require('web.session'); var datepicker = require('web.datepicker'); var time = require('web.time'); @@ -75,7 +75,6 @@ odoo.define('dynamic_cash_flow_statements.cash_flow', function(require) { widgetParent: 'body', allowInputToggle: true, }; - $calendarInputGroup.datetimepicker(calendarOptions); }, @@ -98,33 +97,20 @@ odoo.define('dynamic_cash_flow_statements.cash_flow', function(require) { rep_lines.total_debit = self.format_currency(datas['currency'], rep_lines.total_debit); rep_lines.total_credit = self.format_currency(datas['currency'], rep_lines.total_credit); rep_lines.balance = self.format_currency(datas['currency'], rep_lines.balance); - - - - }); - }); _.each(datas['account_res'], function(journal_lines) { _.each(journal_lines['journal_lines'], function(rep_lines) { rep_lines.total_debit = self.format_currency(datas['currency'], rep_lines.total_debit); rep_lines.total_credit = self.format_currency(datas['currency'], rep_lines.total_credit); rep_lines.total_balance = self.format_currency(datas['currency'], rep_lines.total_balance); - - }); _.each(journal_lines['move_lines'], function(move_lines) { move_lines.total_debit = self.format_currency(datas['currency'], move_lines.total_debit); move_lines.total_credit = self.format_currency(datas['currency'], move_lines.total_credit); move_lines.balance = self.format_currency(datas['currency'], move_lines.balance); - - - - }); }); - - if (datas['levels'] == 'detailed') { $(event.currentTarget).next('tr').find('td ul').after( QWeb.render('SubSectionCF', { @@ -155,7 +141,6 @@ odoo.define('dynamic_cash_flow_statements.cash_flow', function(require) { } }, - load_data: function(initial_render = true) { var self = this; self.$(".categ").empty(); @@ -168,16 +153,10 @@ odoo.define('dynamic_cash_flow_statements.cash_flow', function(require) { [this.wizard_id] ], }).then(function(datas) { - - _.each(datas['fetched_data'], function(rep_lines) { rep_lines.total_debit = self.format_currency(datas['currency'], rep_lines.total_debit); rep_lines.total_credit = self.format_currency(datas['currency'], rep_lines.total_credit); rep_lines.total_balance = self.format_currency(datas['currency'], rep_lines.total_balance); - - - - }); if (initial_render) { self.$('.filter_view_tb').html(QWeb.render('CashFilterView', { @@ -196,7 +175,7 @@ odoo.define('dynamic_cash_flow_statements.cash_flow', function(require) { var child = []; self.$('.table_view_tb').html(QWeb.render('CashTable', { - + lang: session.bundle_params.lang, account_data: datas['fetched_data'], level: datas['levels'], currency: datas['currency'], @@ -235,11 +214,8 @@ odoo.define('dynamic_cash_flow_statements.cash_flow', function(require) { domain: [ ['account_ids', '=', account_id] ], - - } return this.do_action(action); - }, print_pdf: function(e) { e.preventDefault(); diff --git a/dynamic_accounts_report/static/src/js/daybook.js b/dynamic_accounts_report/static/src/js/daybook.js index ac90ff0ee..e5231cee4 100644 --- a/dynamic_accounts_report/static/src/js/daybook.js +++ b/dynamic_accounts_report/static/src/js/daybook.js @@ -296,7 +296,6 @@ odoo.define('dynamic_partner_daybook.daybook', function(require) { }, view_acc_move: function(event) { - event.preventDefault(); var self = this; var context = {}; @@ -325,7 +324,6 @@ odoo.define('dynamic_partner_daybook.daybook', function(require) { limit: 1, }) .then(function(record) { - if (record.length > 0) { show_acc_move('account.move', record[0].id); } else { diff --git a/dynamic_accounts_report/static/src/js/general_ledger.js b/dynamic_accounts_report/static/src/js/general_ledger.js index f0c02c334..b8dbdb242 100644 --- a/dynamic_accounts_report/static/src/js/general_ledger.js +++ b/dynamic_accounts_report/static/src/js/general_ledger.js @@ -279,7 +279,6 @@ odoo.define('dynamic_accounts_report.general_ledger', function(require) { // }); for (var i = 0; i < data['report_lines'].length; i++) { - if (account_id == data['report_lines'][i]['id']) { $(event.currentTarget).next('tr').find('td').remove(); $(event.currentTarget).next('tr').after( @@ -291,7 +290,7 @@ odoo.define('dynamic_accounts_report.general_ledger', function(require) { })) $(event.currentTarget).next('tr').find('td ul li:first a').css({ - 'background-color': '#00ede8', + 'background-color': '#fcba03', 'font-weight': 'bold', }); } diff --git a/dynamic_accounts_report/static/src/xml/cash_flow_view.xml b/dynamic_accounts_report/static/src/xml/cash_flow_view.xml index 259470067..d76171db5 100644 --- a/dynamic_accounts_report/static/src/xml/cash_flow_view.xml +++ b/dynamic_accounts_report/static/src/xml/cash_flow_view.xml @@ -47,30 +47,39 @@ - + + + + + + + + + + @@ -89,31 +98,40 @@ - - + + + + + + + + + + + @@ -255,24 +273,24 @@ Level: @@ -318,15 +336,15 @@ Level: @@ -336,12 +354,12 @@ Level: @@ -361,4 +379,4 @@ Level: - \ No newline at end of file + diff --git a/dynamic_accounts_report/wizard/ageing.py b/dynamic_accounts_report/wizard/ageing.py index e23dc90f9..e5c22997d 100644 --- a/dynamic_accounts_report/wizard/ageing.py +++ b/dynamic_accounts_report/wizard/ageing.py @@ -158,7 +158,6 @@ class AgeingView(models.TransientModel): 'docs': docs, 'time': time, 'Partners': account_res, - } @api.model @@ -182,7 +181,6 @@ class AgeingView(models.TransientModel): 'partner_category_ids')]}) if not vals.get('partner_category_ids'): vals.update({'partner_category_ids': [(5,)]}) - res = super(AgeingView, self).write(vals) return res @@ -536,7 +534,6 @@ class AgeingView(models.TransientModel): return currency_array def get_dynamic_xlsx_report(self, data, response, report_data, dfr_data): - report_data_main = json.loads(report_data) output = io.BytesIO() filters = json.loads(data) @@ -630,7 +627,7 @@ class AgeingView(models.TransientModel): sheet.write(row, col, line_data.get('move'), txt) sheet.write(row, col + 1, line_data.get('date'), txt) sheet.write(row, col + 2, line_data.get('jrnl'), txt) - sheet.write(row, col + 3, line_data.get('acc_code'), txt) + sheet.write(row, col + 3, f'({line_data.get("acc_code")}){line_data.get("acc_name")}', txt) if line_data.get('period6'): sheet.write(row, col + 4, line_data.get('amount'), txt) else: diff --git a/dynamic_accounts_report/wizard/balance_sheet.py b/dynamic_accounts_report/wizard/balance_sheet.py index 2fb3b171b..a076d3ce4 100644 --- a/dynamic_accounts_report/wizard/balance_sheet.py +++ b/dynamic_accounts_report/wizard/balance_sheet.py @@ -114,7 +114,6 @@ class BalanceSheetView(models.TransientModel): 'report_lines'] move_line_accounts = [] move_lines_dict = {} - for rec in records['Accounts']: move_line_accounts.append(rec['id']) move_lines_dict[rec['id']] = {} @@ -226,6 +225,15 @@ class BalanceSheetView(models.TransientModel): rec['credit']) + " " + symbol rec['m_balance'] = "{:,.2f}".format( rec['balance']) + " " + symbol + user = self.env.user + user_language = user.lang + 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'] + else: + item['new_name'] = item['name'] return { 'name': tag, 'type': 'ir.actions.client', @@ -369,6 +377,22 @@ class BalanceSheetView(models.TransientModel): raise UserError(_("No Accounts Found! Please Add One")) account_res = self._get_accounts(accounts, init_balance, display_account, data) + current_lang = self.env.user.lang + list_ac = [] + default_lg = self.env['ir.http']._get_default_lang() + for rec in account_res: + list_ac.append(rec['account_id']) + if rec.get('name', None): + localized_name = rec['name'] + if localized_name: + 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. + else: + # Handle the case where 'name' is not present in the dictionary. + rec['name'] = '' # You can use an debit_total = 0 debit_total = sum(x['debit'] for x in account_res) credit_total = sum(x['credit'] for x in account_res) @@ -457,7 +481,7 @@ class BalanceSheetView(models.TransientModel): # if data['analytic_tags']: # WHERE += ' AND anltag.account_analytic_tag_id IN %s' % str( # tuple(data.get('analytic_tags').ids) + tuple([0])) - + # current_lang = self.env.user.lang # 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, ROUND(COALESCE(SUM(l.debit),0),2) AS debit, diff --git a/dynamic_accounts_report/wizard/cash_flow.py b/dynamic_accounts_report/wizard/cash_flow.py index 67e8567a6..802716359 100644 --- a/dynamic_accounts_report/wizard/cash_flow.py +++ b/dynamic_accounts_report/wizard/cash_flow.py @@ -22,9 +22,11 @@ from datetime import datetime from odoo import models, api, fields + FETCH_RANGE = 2000 import io import json + try: from odoo.tools.misc import xlsxwriter except ImportError: @@ -36,7 +38,7 @@ class AccountCasgFlow(models.TransientModel): _name = "account.cash.flow" _inherit = "account.report" - date_from = fields.Date(string="Start Date", default=str(year)+'-01-01') + date_from = fields.Date(string="Start Date", default=str(year) + '-01-01') date_to = fields.Date(string="End Date", default=fields.Date.today) today = fields.Date(string="Report Date", default=fields.Date.today) levels = fields.Selection([('summary', 'Summary'), @@ -77,6 +79,25 @@ class AccountCasgFlow(models.TransientModel): journal_res = report_lines['journal_res'] levels = report_lines['levels'] currency = self._get_currency() + user = self.env.user + user_language = user.lang + for data in fetched_data: + if filters['levels'] != 'summary': + language_name = data.get('name') + if isinstance(language_name, dict): + data['account'] = language_name[ + user_language] if user_language in language_name else \ + language_name['en_US'] + else: + data['account'] = data.get('name') + for rec in journal_res: + for item in rec.get('journal_lines'): + if isinstance(item['name'], dict): + item['new_name'] = item['name'][ + user_language] if user_language in item['name'] else \ + item['name']['en_US'] + else: + item['new_name'] = data.get('name') return { 'name': "Cash Flow Statements", 'type': 'ir.actions.client', @@ -143,7 +164,7 @@ class AccountCasgFlow(models.TransientModel): filter_dict.update(default_filters) return filter_dict - def _get_report_values(self, data,option): + def _get_report_values(self, data, option): cr = self.env.cr data = self.get_filter(option) company_id = self.env.company @@ -158,8 +179,10 @@ class AccountCasgFlow(models.TransientModel): account_type_id = 'asset_cash' model = self.env.context.get('active_model') if data.get('levels') == 'summary': - state = """ AND am.state = 'posted' """ if data.get('target_move') == 'Posted' else '' - state2 = ' AND aml.company_id IN %s' % str(tuple(self.env.companies.ids) + tuple([0])) + state = """ AND am.state = 'posted' """ if data.get( + 'target_move') == 'Posted' else '' + state2 = ' AND aml.company_id IN %s' % str( + tuple(self.env.companies.ids) + tuple([0])) query3 = """SELECT to_char(am.date, 'Month') as month_part, extract(YEAR from am.date) as year_part, sum(aml.debit) AS total_debit, sum(aml.credit) AS @@ -171,7 +194,7 @@ class AccountCasgFlow(models.TransientModel): WHERE am.date BETWEEN '""" + str( data.get('date_from')) + """' and '""" + str( data.get('date_to')) + """' AND aa.account_type='""" + str( - account_type_id) + """' """ + state + state2 +""") am + account_type_id) + """' """ + state + state2 + """) am LEFT JOIN account_move_line aml ON aml.move_id = am.id LEFT JOIN account_account aa ON aa.id = aml.account_id GROUP BY month_part,year_part""" @@ -183,7 +206,8 @@ class AccountCasgFlow(models.TransientModel): state = """AND am.state = 'posted' """ if data.get( 'target_move') == 'Posted' else """AND am.state in ('draft','posted') """ - state2 = ' AND aml.company_id IN %s' % str(tuple(self.env.companies.ids) + tuple([0])) + state2 = ' AND aml.company_id IN %s' % str( + tuple(self.env.companies.ids) + tuple([0])) sql = """SELECT DISTINCT aa.id, aa.name,aa.code, sum(aml.debit) AS total_debit, sum(aml.credit) AS total_credit,sum(aml.balance) AS total_balance FROM (SELECT am.* FROM account_move as am @@ -192,7 +216,7 @@ class AccountCasgFlow(models.TransientModel): WHERE am.date BETWEEN '""" + str( data.get('date_from')) + """' and '""" + str( data.get('date_to')) + """' AND aa.account_type='""" + str( - account_type_id) + """' """ + state + state2 +""") am + account_type_id) + """' """ + state + state2 + """) am LEFT JOIN account_move_line aml ON aml.move_id = am.id LEFT JOIN account_account aa ON aa.id = aml.account_id GROUP BY aa.name, aa.code,aa.id""" @@ -204,7 +228,8 @@ class AccountCasgFlow(models.TransientModel): state = """AND am.state = 'posted' """ if data.get( 'target_move') == 'Posted' else """AND am.state in ('draft','posted') """ - state2 = ' AND aml.company_id IN %s' % str(tuple(self.env.companies.ids) + tuple([0])) + state2 = ' AND aml.company_id IN %s' % str( + tuple(self.env.companies.ids) + tuple([0])) sql = """SELECT DISTINCT aa.id, aa.name,aa.code, sum(aml.debit) AS total_debit, sum(aml.credit) AS total_credit,sum(aml.balance) AS total_balance FROM (SELECT am.* FROM account_move as am @@ -225,7 +250,8 @@ class AccountCasgFlow(models.TransientModel): state = """AND am.state = 'posted' """ if data.get( 'target_move') == 'Posted' else """AND am.state in ('draft','posted') """ - state2 = ' AND aml.company_id IN %s' % str(tuple(self.env.companies.ids) + tuple([0])) + state2 = ' AND aml.company_id IN %s' % str( + tuple(self.env.companies.ids) + tuple([0])) sql = """SELECT DISTINCT aa.id, aa.name,aa.code, sum(aml.debit) AS total_debit, sum(aml.credit) AS total_credit,sum(aml.balance) AS total_balance FROM (SELECT am.* FROM account_move as am @@ -247,7 +273,8 @@ class AccountCasgFlow(models.TransientModel): state = """AND am.state = 'posted' """ if data.get( 'target_move') == 'Posted' else """AND am.state in ('draft','posted') """ - state2 = ' AND aml.company_id IN %s' % str(tuple(self.env.companies.ids) + tuple([0])) + state2 = ' AND aml.company_id IN %s' % str( + tuple(self.env.companies.ids) + tuple([0])) sql = """SELECT DISTINCT aa.id, aa.name,aa.code, sum(aml.debit) AS total_debit, sum(aml.credit) AS total_credit,sum(aml.balance) AS total_balance FROM (SELECT am.* FROM account_move as am @@ -265,24 +292,29 @@ class AccountCasgFlow(models.TransientModel): fetched_data = cr.dictfetchall() elif data.get('levels') == 'consolidated': - state = """ AND am.state = 'posted' """ if data.get('target_move') == 'Posted' else '' - state2 = ' AND aml.company_id IN %s' % str(tuple(self.env.companies.ids) + tuple([0])) - query2 = """SELECT aat.name, sum(aml.debit) AS total_debit, sum(aml.credit) AS total_credit, + state = """ AND am.state = 'posted' """ if data.get( + 'target_move') == 'Posted' else '' + state2 = ' AND aml.company_id IN %s' % str( + tuple(self.env.companies.ids) + tuple([0])) + query2 = """SELECT aa.name, sum(aml.debit) AS total_debit, sum(aml.credit) AS total_credit, sum(aml.balance) AS total_balance FROM ( SELECT am.id, am.state FROM account_move as am LEFT JOIN account_move_line aml ON aml.move_id = am.id LEFT JOIN account_account aa ON aa.id = aml.account_id - WHERE am.date BETWEEN '""" + str(data.get('date_from')) + """' and '""" + str( + WHERE am.date BETWEEN '""" + str( + data.get('date_from')) + """' and '""" + str( data.get('date_to')) + """' AND aa.account_type='""" + str( account_type_id) + """' """ + state + state2 + """) am LEFT JOIN account_move_line aml ON aml.move_id = am.id LEFT JOIN account_account aa ON aa.id = aml.account_id - GROUP BY aat.name""" + GROUP BY aa.name""" cr = self._cr cr.execute(query2) fetched_data = cr.dictfetchall() elif data.get('levels') == 'detailed': - state = """AND am.state = 'posted' """ if data.get('target_move') == 'Posted' else """AND am.state in ('draft','posted') """ - state2 = ' AND aml.company_id IN %s' % str(tuple(self.env.companies.ids) + tuple([0])) + state = """AND am.state = 'posted' """ if data.get( + 'target_move') == 'Posted' else """AND am.state in ('draft','posted') """ + state2 = ' AND aml.company_id IN %s' % str( + tuple(self.env.companies.ids) + tuple([0])) query1 = """SELECT aa.id,aa.name,aa.code, sum(aml.debit) AS total_debit, sum(aml.credit) AS total_credit, sum(aml.balance) AS total_balance FROM (SELECT am.id, am.state FROM account_move as am LEFT JOIN account_move_line aml ON aml.move_id = am.id @@ -304,8 +336,10 @@ class AccountCasgFlow(models.TransientModel): else: account_type_id = 'asset_cash' - state = """AND am.state = 'posted' """ if data.get('target_move') == 'Posted' else """AND am.state in ('draft','posted') """ - state2 = ' AND aml.company_id IN %s' % str(tuple(self.env.companies.ids) + tuple([0])) + state = """AND am.state = 'posted' """ if data.get( + 'target_move') == 'Posted' else """AND am.state in ('draft','posted') """ + state2 = ' AND aml.company_id IN %s' % str( + tuple(self.env.companies.ids) + tuple([0])) # filter = " AND aml.parent_state in ('draft','posted')" sql = """SELECT DISTINCT aa.id, aa.name,aa.code, sum(aml.debit) AS total_debit, sum(aml.credit) AS total_credit,sum(aml.balance) AS total_balance @@ -315,7 +349,7 @@ class AccountCasgFlow(models.TransientModel): WHERE am.date BETWEEN '""" + str( data.get('date_from')) + """' and '""" + str( data.get('date_to')) + """' AND aa.account_type='""" + str( - account_type_id) + """' """ + state + state2 +""") am + account_type_id) + """' """ + state + state2 + """) am LEFT JOIN account_move_line aml ON aml.move_id = am.id LEFT JOIN account_account aa ON aa.id = aml.account_id GROUP BY aa.name, aa.code,aa.id""" @@ -329,7 +363,6 @@ class AccountCasgFlow(models.TransientModel): journals = self.get_journal_lines(account, data) if journals: journal_res.append(journals) - return { 'date_from': data.get('date_from'), 'date_to': data.get('date_to'), @@ -347,8 +380,10 @@ class AccountCasgFlow(models.TransientModel): def _get_lines(self, account, data): account_type_id = 'asset_cash' - state = """AND am.state = 'posted' """ if data.get('target_move') == 'Posted' else """AND am.state in ('draft','posted') """ - state2 = ' AND aml.company_id IN %s' % str(tuple(self.env.companies.ids) + tuple([0])) + state = """AND am.state = 'posted' """ if data.get( + 'target_move') == 'Posted' else """AND am.state in ('draft','posted') """ + state2 = ' AND aml.company_id IN %s' % str( + tuple(self.env.companies.ids) + tuple([0])) query = """SELECT aml.account_id,aj.id as j_id,aj.name,am.id, am.name as move_name, sum(aml.debit) AS total_debit, sum(aml.credit) AS total_credit, COALESCE(SUM(aml.debit - aml.credit),0) AS balance FROM (SELECT am.* FROM account_move as am LEFT JOIN account_move_line aml ON aml.move_id = am.id @@ -394,12 +429,14 @@ class AccountCasgFlow(models.TransientModel): 'journal_lines': fetch_data, } - - def get_journal_lines(self, account, data, offset=0, fetch_range=FETCH_RANGE): + def get_journal_lines(self, account, data, offset=0, + fetch_range=FETCH_RANGE): account_type_id = 'asset_cash' offset_count = offset * fetch_range - state = """AND am.state = 'posted' """ if data.get('target_move') == 'Posted' else """AND am.state in ('draft','posted') """ - state2 = ' AND aml.company_id IN %s' % str(tuple(self.env.companies.ids) + tuple([0])) + state = """AND am.state = 'posted' """ if data.get( + 'target_move') == 'Posted' else """AND am.state in ('draft','posted') """ + state2 = ' AND aml.company_id IN %s' % str( + tuple(self.env.companies.ids) + tuple([0])) sql2 = """SELECT aa.name as account_name, aj.name, sum(aml.debit) AS total_debit, sum(aml.credit) AS total_credit, COALESCE(SUM(aml.debit - aml.credit),0) AS balance FROM (SELECT am.* FROM account_move as am LEFT JOIN account_move_line aml ON aml.move_id = am.id @@ -425,9 +462,6 @@ class AccountCasgFlow(models.TransientModel): 'offset': offset_count, } - - - @api.model def create(self, vals): vals['target_move'] = 'posted' @@ -443,7 +477,8 @@ class AccountCasgFlow(models.TransientModel): if vals.get('journal_ids') == []: vals.update({'journal_ids': [(5,)]}) if vals.get('account_ids'): - vals.update({'account_ids': [(4, j) for j in vals.get('account_ids')]}) + vals.update( + {'account_ids': [(4, j) for j in vals.get('account_ids')]}) if vals.get('account_ids') == []: vals.update({'account_ids': [(5,)]}) @@ -465,6 +500,8 @@ class AccountCasgFlow(models.TransientModel): return currency_array def get_dynamic_xlsx_report(self, data, response, report_data, dfr_data): + user = self.env.user + user_language = user.lang report_main_data = json.loads(dfr_data) data = json.loads(data) report_data = report_main_data.get('report_lines') @@ -477,8 +514,8 @@ class AccountCasgFlow(models.TransientModel): # account_type_id = self.env.ref('account.data_account_type_liquidity').id currency_symbol = self.env.company.currency_id.symbol - - logged_users = self.env['res.company']._company_default_get('account.account') + logged_users = self.env['res.company']._company_default_get( + 'account.account') sheet = workbook.add_worksheet() bold = workbook.add_format({'align': 'center', 'bold': True, @@ -541,38 +578,84 @@ class AccountCasgFlow(models.TransientModel): for i_rec in fetched_data_list: if data['levels'] == 'summary': - sheet.write(row_num + 1, col_num, str(i_rec['month_part']) + str(int(i_rec['year_part'])), txt_left) - sheet.write(row_num + 1, col_num + 1, str(i_rec['total_debit']) + str(currency_symbol), amount) - sheet.write(row_num + 1, col_num + 2, str(i_rec['total_credit']) + str(currency_symbol), amount) + sheet.write(row_num + 1, col_num, + str(i_rec['month_part']) + str( + int(i_rec['year_part'])), txt_left) + sheet.write(row_num + 1, col_num + 1, + str(i_rec['total_debit']) + str(currency_symbol), + amount) + sheet.write(row_num + 1, col_num + 2, + str(i_rec['total_credit']) + str(currency_symbol), + amount) sheet.write(row_num + 1, col_num + 3, - str(i_rec['total_debit'] - i_rec['total_credit']) + str(currency_symbol), + str(i_rec['total_debit'] - i_rec[ + 'total_credit']) + str(currency_symbol), amount) row_num = row_num + 1 elif data['levels'] == 'consolidated': - sheet.write(row_num + 1, col_num, i_rec['name'], txt_left) - sheet.write(row_num + 1, col_num + 1, str(i_rec['total_debit']) + str(currency_symbol), amount) - sheet.write(row_num + 1, col_num + 2, str(i_rec['total_credit']) + str(currency_symbol), amount) + langs = i_rec['name'] + if isinstance(langs, dict): + language = user_language if user_language in langs else 'en_US' + sheet.write(row_num + 1, col_num, i_rec['name'][language], + txt_left) + else: + sheet.write(row_num + 1, col_num, i_rec['name'], + txt_left) + sheet.write(row_num + 1, col_num + 1, + str(i_rec['total_debit']) + str(currency_symbol), + amount) + sheet.write(row_num + 1, col_num + 2, + str(i_rec['total_credit']) + str(currency_symbol), + amount) sheet.write(row_num + 1, col_num + 3, - str(i_rec['total_debit'] - i_rec['total_credit']) + str(currency_symbol), + str(i_rec['total_debit'] - i_rec[ + 'total_credit']) + str(currency_symbol), amount) row_num = row_num + 1 for j_rec in journal_res_list: if data['levels'] == 'detailed': for k in fetched_data_list: + language_two = user_language if user_language in k[ + 'name'] else 'en_US' if k['id'] == j_rec['id']: - sheet.write(row_num + 1, col_num, str(k['code']) + str(k['name']), txt_bold) - sheet.write(row_num + 1, col_num + 1, str(k['total_debit']) + str(currency_symbol), amount_bold) - sheet.write(row_num + 1, col_num + 2, str(k['total_credit']) + str(currency_symbol), amount_bold) + if isinstance(k['name'], dict): + sheet.write(row_num + 1, col_num, + str(k['code']) + str( + k['name'][language_two]), txt_bold) + else: + sheet.write(row_num + 1, col_num, + str(k['code']) + str( + k['name']), txt_bold) + sheet.write(row_num + 1, col_num + 1, + str(k['total_debit']) + str( + currency_symbol), amount_bold) + sheet.write(row_num + 1, col_num + 2, + str(k['total_credit']) + str( + currency_symbol), amount_bold) sheet.write(row_num + 1, col_num + 3, - str(k['total_debit'] - k['total_credit']) + str(currency_symbol), amount_bold) + str(k['total_debit'] - k[ + 'total_credit']) + str(currency_symbol), + amount_bold) row_num = row_num + 1 for l_jrec in j_rec['journal_lines']: - sheet.write(row_num + 1, col_num, l_jrec['name'], txt_left) - sheet.write(row_num + 1, col_num + 1, str(l_jrec['total_debit']) + str(currency_symbol), amount) - sheet.write(row_num + 1, col_num + 2, str(l_jrec['total_credit']) + str(currency_symbol), amount) + language_one = user_language if user_language in l_jrec[ + 'name'] else 'en_US' + if isinstance(l_jrec['name'], dict): + sheet.write(row_num + 1, col_num, + l_jrec['name'][language_one], txt_left) + else: + sheet.write(row_num + 1, col_num, + l_jrec['name'], txt_left) + sheet.write(row_num + 1, col_num + 1, + str(l_jrec['total_debit']) + str( + currency_symbol), amount) + sheet.write(row_num + 1, col_num + 2, + str(l_jrec['total_credit']) + str( + currency_symbol), amount) sheet.write(row_num + 1, col_num + 3, - str(l_jrec['total_debit'] - l_jrec['total_credit']) + str(currency_symbol), + str(l_jrec['total_debit'] - l_jrec[ + 'total_credit']) + str(currency_symbol), amount) row_num = row_num + 1 @@ -580,32 +663,60 @@ class AccountCasgFlow(models.TransientModel): if data['levels'] == 'very': for k in fetched_data_list: if k['id'] == j_rec['id']: - sheet.write(row_num + 1, col_num, str(k['code']) + str(k['name']), txt_bold) - sheet.write(row_num + 1, col_num + 1, str(k['total_debit']) + str(currency_symbol), amount_bold) - sheet.write(row_num + 1, col_num + 2, str(k['total_credit']) + str(currency_symbol), amount_bold) + all_lang = k['name'] + language_four = user_language if user_language in all_lang else 'en_US' + if isinstance(all_lang, dict): + sheet.write(row_num + 1, col_num, + str(k['code']) + str( + k['name'][language_four]), txt_bold) + else: + sheet.write(row_num + 1, col_num, + str(k['code']) + str( + k['name']), txt_bold) + sheet.write(row_num + 1, col_num + 1, + str(k['total_debit']) + str( + currency_symbol), amount_bold) + sheet.write(row_num + 1, col_num + 2, + str(k['total_credit']) + str( + currency_symbol), amount_bold) sheet.write(row_num + 1, col_num + 3, - str(k['total_debit'] - k['total_credit']) + str(currency_symbol), amount_bold) + str(k['total_debit'] - k[ + 'total_credit']) + str(currency_symbol), + amount_bold) row_num = row_num + 1 for l_jrec in j_rec['journal_lines']: if l_jrec['account_name'] == j_rec['account']: - sheet.write(row_num + 1, col_num, l_jrec['name'], txt_left) - sheet.write(row_num + 1, col_num + 1, str(l_jrec['total_debit']) + str(currency_symbol), amount) - sheet.write(row_num + 1, col_num + 2, str(l_jrec['total_credit']) + str(currency_symbol), amount) + sheet.write(row_num + 1, col_num, l_jrec['name'], + txt_left) + sheet.write(row_num + 1, col_num + 1, + str(l_jrec['total_debit']) + str( + currency_symbol), amount) + sheet.write(row_num + 1, col_num + 2, + str(l_jrec['total_credit']) + str( + currency_symbol), amount) sheet.write(row_num + 1, col_num + 3, - str(l_jrec['total_debit'] - l_jrec['total_credit']) + str(currency_symbol), + str(l_jrec['total_debit'] - l_jrec[ + 'total_credit']) + str(currency_symbol), amount) row_num = row_num + 1 for m_rec in j_rec['move_lines']: if m_rec['name'] == l_jrec['name']: - sheet.write(row_num + 1, col_num, m_rec['move_name'], txt_center) - sheet.write(row_num + 1, col_num + 1, str(m_rec['total_debit']) + str(currency_symbol), amount) - sheet.write(row_num + 1, col_num + 2, str(m_rec['total_credit']) + str(currency_symbol), amount) + sheet.write(row_num + 1, col_num, + m_rec['move_name'], txt_center) + sheet.write(row_num + 1, col_num + 1, + str(m_rec['total_debit']) + str( + currency_symbol), amount) + sheet.write(row_num + 1, col_num + 2, + str(m_rec['total_credit']) + str( + currency_symbol), amount) sheet.write(row_num + 1, col_num + 3, - str(m_rec['total_debit'] - m_rec['total_credit']) + str(currency_symbol), + str(m_rec['total_debit'] - m_rec[ + 'total_credit']) + str( + currency_symbol), amount) row_num = row_num + 1 workbook.close() output.seek(0) response.stream.write(output.read()) - output.close() \ No newline at end of file + output.close() diff --git a/dynamic_accounts_report/wizard/general_ledger.py b/dynamic_accounts_report/wizard/general_ledger.py index b701c2a72..457dc29d5 100644 --- a/dynamic_accounts_report/wizard/general_ledger.py +++ b/dynamic_accounts_report/wizard/general_ledger.py @@ -107,6 +107,20 @@ class GeneralView(models.TransientModel): filters = self.get_filter(option) records = self._get_report_value(data) currency = self._get_currency() + default_lg = self.env['ir.http']._get_default_lang().code + user = self.env.user + user_language = user.lang + 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'] + 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] return { 'name': title, 'type': 'ir.actions.client', @@ -230,9 +244,23 @@ class GeneralView(models.TransientModel): raise UserError(_("No Accounts Found! Please Add One")) account_res = self._get_accounts(accounts, init_balance, display_account, data) + current_lang = self.env.user.lang + list_ac = [] + default_lg = self.env['ir.http']._get_default_lang() for rec in account_res: list_ac.append(rec['account_id']) + if rec.get('name', None): + localized_name = rec['name'] + if localized_name: + 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. + else: + # Handle the case where 'name' is not present in the dictionary. + rec['name'] = '' # You can use an + title = "General Ledger" account_line = self.get_accounts_line(list_ac, title)['report_lines'] acc_line_list = [] @@ -289,7 +317,6 @@ class GeneralView(models.TransientModel): vals.update({'account_tag_ids': [(5,)]}) # Analytic filter if vals.get('analytic_ids'): - # print("lllllllllllllll",vals['analytic_ids']) vals.update({'analytic_ids': [(6, 0, vals.get('analytic_ids'))]}) if vals.get('analytic_ids') == []: vals.update({'analytic_ids': [(5,)]}) @@ -328,9 +355,7 @@ class GeneralView(models.TransientModel): tuple(data.get('accounts').ids) + tuple([0])) else: WHERE = "WHERE l.account_id IN %s" - if data.get('analytics'): - # print("Analytic account filter woking in GL") WHERE += ' AND an.id IN %s' % str( tuple(data.get('analytics').ids) + tuple([0])) if data['account_tags']: @@ -397,7 +422,6 @@ class GeneralView(models.TransientModel): 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])) - print('genrl ledger where !!!',WHERE) # Get move lines base on sql query and Calculate the total balance # of move lines @@ -561,6 +585,8 @@ class GeneralView(models.TransientModel): } def get_dynamic_xlsx_report(self, data, response, report_data, dfr_data): + user = self.env.user + user_language = user.lang report_data_main = json.loads(report_data) output = io.BytesIO() name_data = json.loads(dfr_data) @@ -620,9 +646,14 @@ class GeneralView(models.TransientModel): sheet.set_column(8, 8, 15) sheet.set_column(8, 9, 15) for rec_data in report_data_main: + language = user_language if user_language in rec_data[ + 'name'] else 'en_US' row += 1 sheet.write(row + 1, col, rec_data['code'], txt) - sheet.write(row + 1, col + 1, rec_data['name'], txt) + if isinstance(rec_data['name'], dict): + sheet.write(row + 1, col + 1, rec_data['name'][language], txt) + else: + sheet.write(row + 1, col + 1, rec_data['name'], txt) sheet.write(row + 1, col + 2, '', txt) sheet.write(row + 1, col + 3, '', txt) sheet.write(row + 1, col + 4, '', txt) diff --git a/dynamic_accounts_report/wizard/partner_leadger.py b/dynamic_accounts_report/wizard/partner_leadger.py index e916f7d3e..5208a4686 100644 --- a/dynamic_accounts_report/wizard/partner_leadger.py +++ b/dynamic_accounts_report/wizard/partner_leadger.py @@ -281,7 +281,6 @@ class PartnerView(models.TransientModel): vals.update({'partner_category_ids': [(5,)]}) # Account Type filter # if vals.get('account_type'): - # print('vals.get account_type..........',vals.get('account_type')) # vals.update( # {'account_type': [(6, 0, vals.get('account_type'))]}) # if not vals.get('account_type'): @@ -444,9 +443,8 @@ class PartnerView(models.TransientModel): 'Target Moves: ' + filters.get('target_move'), date_head) - sheet.merge_range('C4:D4', 'Account Type: ' + ', '.join( - [lt or '' for lt in - filters['account_type']]), + sheet.merge_range('C4:D4', 'Account Type: ' + + filters['account_type'], date_head) sheet.merge_range('E3:F3', ' Partners: ' + ', '.join( [lt or '' for lt in
+ - - - - - - - - - - cash_flow account.cash.flow diff --git a/dynamic_accounts_report/report/daybook.py b/dynamic_accounts_report/report/daybook.py index 87de32376..b80736b6e 100644 --- a/dynamic_accounts_report/report/daybook.py +++ b/dynamic_accounts_report/report/daybook.py @@ -27,7 +27,6 @@ class DayBook(models.AbstractModel): @api.model def _get_report_values(self,docids, data=None): - if self.env.context.get('daybook_pdf_report'): if data.get('report_data'): diff --git a/dynamic_accounts_report/report/financial_report_template.xml b/dynamic_accounts_report/report/financial_report_template.xml index 69bf8e820..577587604 100644 --- a/dynamic_accounts_report/report/financial_report_template.xml +++ b/dynamic_accounts_report/report/financial_report_template.xml @@ -64,14 +64,14 @@ - - - - - - - - + + + + + + + +
Target move: @@ -90,7 +90,7 @@
Debit CreditBalance001Balance
diff --git a/dynamic_accounts_report/report/general_ledger.py b/dynamic_accounts_report/report/general_ledger.py index 2b81b1d75..5f7cc2da3 100644 --- a/dynamic_accounts_report/report/general_ledger.py +++ b/dynamic_accounts_report/report/general_ledger.py @@ -27,7 +27,6 @@ class GeneralLedger(models.AbstractModel): @api.model def _get_report_values(self, docids, data=None): - print('_get_report_values........',data) if self.env.context.get('trial_pdf_report'): if data.get('report_data'): data.update( diff --git a/dynamic_accounts_report/report/general_ledger.xml b/dynamic_accounts_report/report/general_ledger.xml index 48edcfb43..c9e1b0232 100644 --- a/dynamic_accounts_report/report/general_ledger.xml +++ b/dynamic_accounts_report/report/general_ledger.xml @@ -10,20 +10,14 @@

:

- From: - - - To: - -
@@ -96,7 +90,7 @@
- + diff --git a/dynamic_accounts_report/report/trial_balance.py b/dynamic_accounts_report/report/trial_balance.py index 62097fabb..b8986032a 100644 --- a/dynamic_accounts_report/report/trial_balance.py +++ b/dynamic_accounts_report/report/trial_balance.py @@ -28,7 +28,6 @@ class TrialBalance(models.AbstractModel): @api.model def _get_report_values(self,docids, data=None): if self.env.context.get('trial_pdf_report'): - if data.get('report_data'): data.update({'account_data': data.get('report_data' )['report_lines'], diff --git a/dynamic_accounts_report/report/trial_balance.xml b/dynamic_accounts_report/report/trial_balance.xml index 9a93033f7..c4e264de4 100644 --- a/dynamic_accounts_report/report/trial_balance.xml +++ b/dynamic_accounts_report/report/trial_balance.xml @@ -79,7 +79,6 @@ - + - + - + - + - + - +
- + - + - + - + - + - +
- + - + - + - + - + - +
- + - + - + - + - +