diff --git a/account_financial_report/report/general_ledger.py b/account_financial_report/report/general_ledger.py index f285af37a0ed..7d07f6f9c661 100644 --- a/account_financial_report/report/general_ledger.py +++ b/account_financial_report/report/general_ledger.py @@ -303,6 +303,10 @@ def _get_move_line_data(self, move_line): move_line['full_reconcile_id'] else "", 'tag_ids': move_line['analytic_tag_ids'], 'currency_id': move_line['currency_id'], + 'analytic_account': move_line['analytic_account_id'][1] if + move_line['analytic_account_id'] else "", + 'analytic_account_id': move_line['analytic_account_id'][0] if + move_line['analytic_account_id'] else False, } if move_line_data['ref'] == move_line_data['name'] or move_line_data[ 'ref'] == '': @@ -399,7 +403,7 @@ def _get_period_ml_data( 'id', 'name', 'date', 'move_id', 'journal_id', 'account_id', 'partner_id', 'debit', 'credit', 'balance', 'currency_id', 'full_reconcile_id', 'tax_ids', 'analytic_tag_ids', - 'amount_currency', 'ref', 'name'] + 'amount_currency', 'ref', 'name', 'analytic_account_id'] move_lines = self.env['account.move.line'].search_read( domain=domain, fields=ml_fields) @@ -595,6 +599,7 @@ def _calculate_centralization(self, centralized_ml, move_line, date_to): 'id': False, 'tag_ids': False, 'currency_id': False, + 'analytic_account': 'Centralized entries', }) centralized_ml[jnl_id][month]['debit'] += move_line['debit'] centralized_ml[jnl_id][month]['credit'] += move_line['credit'] @@ -696,6 +701,7 @@ def _get_report_values(self, docids, data): 'only_posted_moves': data['only_posted_moves'], 'hide_account_at_0': data['hide_account_at_0'], 'show_analytic_tags': data['show_analytic_tags'], + 'show_cost_center': data['show_cost_center'], 'general_ledger': general_ledger, 'accounts_data': accounts_data, 'partners_data': partners_data, diff --git a/account_financial_report/report/general_ledger_xlsx.py b/account_financial_report/report/general_ledger_xlsx.py index c23a1dbaba45..da3f03c434d1 100644 --- a/account_financial_report/report/general_ledger_xlsx.py +++ b/account_financial_report/report/general_ledger_xlsx.py @@ -22,59 +22,69 @@ def _get_report_name(self, report, data=False): return report_name def _get_report_columns(self, report): - res = { - 0: {'header': _('Date'), 'field': 'date', 'width': 11}, - 1: {'header': _('Entry'), 'field': 'entry', 'width': 18}, - 2: {'header': _('Journal'), 'field': 'journal', 'width': 8}, - 3: {'header': _('Account'), 'field': 'account', 'width': 9}, - 4: {'header': _('Taxes'), + res = [ + {'header': _('Date'), 'field': 'date', 'width': 11}, + {'header': _('Entry'), 'field': 'entry', 'width': 18}, + {'header': _('Journal'), 'field': 'journal', 'width': 8}, + {'header': _('Account'), 'field': 'account', 'width': 9}, + {'header': _('Taxes'), 'field': 'taxes_description', 'width': 15}, - 5: {'header': _('Partner'), 'field': 'partner_name', 'width': 25}, - 6: {'header': _('Ref - Label'), 'field': 'ref_label', 'width': 40}, - 7: {'header': _('Cost center'), - 'field': 'cost_center', - 'width': 15}, - 8: {'header': _('Tags'), - 'field': 'tags', - 'width': 10}, - 9: {'header': _('Rec.'), 'field': 'rec_name', 'width': 15}, - 10: {'header': _('Debit'), - 'field': 'debit', - 'field_initial_balance': 'initial_debit', - 'field_final_balance': 'final_debit', - 'type': 'amount', - 'width': 14}, - 11: {'header': _('Credit'), - 'field': 'credit', - 'field_initial_balance': 'initial_credit', - 'field_final_balance': 'final_credit', - 'type': 'amount', - 'width': 14}, - 12: {'header': _('Cumul. Bal.'), - 'field': 'balance', - 'field_initial_balance': 'initial_balance', - 'field_final_balance': 'final_balance', - 'type': 'amount', - 'width': 14}, - } + {'header': _('Partner'), 'field': 'partner_name', 'width': 25}, + {'header': _('Ref - Label'), 'field': 'ref_label', 'width': 40}, + ] + if report.show_cost_center: + res += [ + {'header': _('Cost center'), + 'field': 'analytic_account', + 'width': 15}, + ] + if report.show_analytic_tags: + res += [ + {'header': _('Tags'), + 'field': 'tags', + 'width': 10}, + ] + res += [ + {'header': _('Rec.'), 'field': 'rec_name', 'width': 15}, + {'header': _('Debit'), + 'field': 'debit', + 'field_initial_balance': 'initial_debit', + 'field_final_balance': 'final_debit', + 'type': 'amount', + 'width': 14}, + {'header': _('Credit'), + 'field': 'credit', + 'field_initial_balance': 'initial_credit', + 'field_final_balance': 'final_credit', + 'type': 'amount', + 'width': 14}, + {'header': _('Cumul. Bal.'), + 'field': 'balance', + 'field_initial_balance': 'initial_balance', + 'field_final_balance': 'final_balance', + 'type': 'amount', + 'width': 14}, + ] if report.foreign_currency: - foreign_currency = { - 13: {'header': _('Cur.'), - 'field': 'currency_name', - 'field_currency_balance': 'currency_name', - 'type': 'currency_name', 'width': 7}, - 14: {'header': _('Amount cur.'), - 'field': 'bal_curr', - 'field_initial_balance': - 'initial_bal_curr', - 'field_final_balance': - 'final_bal_curr', - 'type': 'amount_currency', - 'width': 14}, - } - res = {**res, **foreign_currency} - return res + res += [ + {'header': _('Cur.'), + 'field': 'currency_name', + 'field_currency_balance': 'currency_name', + 'type': 'currency_name', 'width': 7}, + {'header': _('Amount cur.'), + 'field': 'bal_curr', + 'field_initial_balance': + 'initial_bal_curr', + 'field_final_balance': + 'final_bal_curr', + 'type': 'amount_currency', + 'width': 14}, + ] + res_as_dict = {} + for i, column in enumerate(res): + res_as_dict[i] = column + return res_as_dict def _get_report_filters(self, report): return [ diff --git a/account_financial_report/report/templates/general_ledger.xml b/account_financial_report/report/templates/general_ledger.xml index 11d662dddf50..d8c1916fe051 100644 --- a/account_financial_report/report/templates/general_ledger.xml +++ b/account_financial_report/report/templates/general_ledger.xml @@ -425,11 +425,11 @@
- - + + style="color: black;">
diff --git a/account_financial_report/wizard/general_ledger_wizard.py b/account_financial_report/wizard/general_ledger_wizard.py index a3d77229371b..a668a049a4c2 100644 --- a/account_financial_report/wizard/general_ledger_wizard.py +++ b/account_financial_report/wizard/general_ledger_wizard.py @@ -99,6 +99,10 @@ class GeneralLedgerReportWizard(models.TransientModel): string='Show Partner Details', default=True, ) + show_cost_center = fields.Boolean( + string='Show Cost Center', + default=True, + ) @api.onchange('account_code_from', 'account_code_to') def on_change_account_range(self): @@ -291,6 +295,7 @@ def _prepare_report_general_ledger(self): 'partner_ids': self.partner_ids.ids, 'show_partner_details': self.show_partner_details, 'cost_center_ids': self.cost_center_ids.ids, + 'show_cost_center': self.show_cost_center, 'analytic_tag_ids': self.analytic_tag_ids.ids, 'journal_ids': self.account_journal_ids.ids, 'centralize': self.centralize, diff --git a/account_financial_report/wizard/general_ledger_wizard_view.xml b/account_financial_report/wizard/general_ledger_wizard_view.xml index 3c578410fb69..b7dc984ca3e4 100644 --- a/account_financial_report/wizard/general_ledger_wizard_view.xml +++ b/account_financial_report/wizard/general_ledger_wizard_view.xml @@ -25,6 +25,7 @@ +