From 6d6937346a3883efebca20756e9bd832ae730a4e Mon Sep 17 00:00:00 2001 From: Carolina Fernandez Date: Mon, 15 Apr 2024 13:37:21 +0200 Subject: [PATCH] [17.0][IMP] account_financial_report: Set custom intervales in aged report --- account_financial_report/__manifest__.py | 3 + .../i18n/account_financial_report.pot | 124 ++- account_financial_report/i18n/es.po | 115 ++- account_financial_report/models/__init__.py | 2 + .../account_age_report_configuration.py | 47 ++ .../models/res_config_settings.py | 14 + account_financial_report/readme/CONFIGURE.md | 26 + .../readme/CONTRIBUTORS.md | 1 + .../readme/DESCRIPTION.md | 4 + .../report/aged_partner_balance.py | 82 +- .../report/aged_partner_balance_xlsx.py | 250 +++--- .../report/templates/aged_partner_balance.xml | 779 ++++++++++-------- .../security/ir.model.access.csv | 2 + .../security/security.xml | 8 + account_financial_report/tests/__init__.py | 1 + .../tests/test_age_report_configuration.py | 42 + .../tests/test_aged_partner_balance.py | 89 +- ...account_age_report_configuration_views.xml | 41 + .../view/res_config_settings_views.xml | 51 ++ .../wizard/aged_partner_balance_wizard.py | 4 + .../aged_partner_balance_wizard_view.xml | 5 +- 21 files changed, 1217 insertions(+), 473 deletions(-) create mode 100644 account_financial_report/models/account_age_report_configuration.py create mode 100644 account_financial_report/models/res_config_settings.py create mode 100644 account_financial_report/readme/CONFIGURE.md create mode 100644 account_financial_report/security/security.xml create mode 100644 account_financial_report/tests/test_age_report_configuration.py create mode 100644 account_financial_report/view/account_age_report_configuration_views.xml create mode 100644 account_financial_report/view/res_config_settings_views.xml diff --git a/account_financial_report/__manifest__.py b/account_financial_report/__manifest__.py index 65c5d31c..e5f5d2fa 100644 --- a/account_financial_report/__manifest__.py +++ b/account_financial_report/__manifest__.py @@ -18,12 +18,14 @@ "depends": ["account", "date_range", "report_xlsx"], "data": [ "security/ir.model.access.csv", + "security/security.xml", "wizard/aged_partner_balance_wizard_view.xml", "wizard/general_ledger_wizard_view.xml", "wizard/journal_ledger_wizard_view.xml", "wizard/open_items_wizard_view.xml", "wizard/trial_balance_wizard_view.xml", "wizard/vat_report_wizard_view.xml", + "view/account_age_report_configuration_views.xml", "menuitems.xml", "reports.xml", "report/templates/layouts.xml", @@ -40,6 +42,7 @@ "view/report_open_items.xml", "view/report_aged_partner_balance.xml", "view/report_vat_report.xml", + "view/res_config_settings_views.xml", ], "assets": { "web.assets_backend": [ diff --git a/account_financial_report/i18n/account_financial_report.pot b/account_financial_report/i18n/account_financial_report.pot index 3e8aaf7e..c0e2bf07 100644 --- a/account_financial_report/i18n/account_financial_report.pot +++ b/account_financial_report/i18n/account_financial_report.pot @@ -6,6 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 17.0\n" "Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-04-15 11:26+0000\n" +"PO-Revision-Date: 2024-04-15 11:26+0000\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -49,6 +51,11 @@ msgstr "" msgid "Taxes summary" msgstr "" +#. module: account_financial_report +#: model_terms:ir.ui.view,arch_db:account_financial_report.res_config_settings_view_form +msgid "Intervals configuration" +msgstr "" + #. module: account_financial_report #: model_terms:ir.ui.view,arch_db:account_financial_report.aged_partner_balance_wizard #: model_terms:ir.ui.view,arch_db:account_financial_report.general_ledger_wizard @@ -89,6 +96,11 @@ msgstr "" msgid "Account" msgstr "" +#. module: account_financial_report +#: model:ir.model.fields,field_description:account_financial_report.field_account_age_report_configuration_line__account_age_report_config_id +msgid "Account Age Report Config" +msgstr "" + #. module: account_financial_report #: model:ir.model.fields,field_description:account_financial_report.field_aged_partner_balance_report_wizard__account_code_from #: model:ir.model.fields,field_description:account_financial_report.field_general_ledger_report_wizard__account_code_from @@ -150,11 +162,16 @@ msgstr "" msgid "Additional Filtering" msgstr "" +#. module: account_financial_report +#: model:ir.actions.act_window,name:account_financial_report.action_aged_partner_report_configuration +msgid "Age Partner Report Configuration" +msgstr "" + #. module: account_financial_report #: model_terms:ir.ui.view,arch_db:account_financial_report.report_aged_partner_balance_move_lines msgid "" -"Age ??? 120\n" -" d." +"Age ≤ 120\n" +" d." msgstr "" #. module: account_financial_report @@ -162,14 +179,14 @@ msgstr "" #: code:addons/account_financial_report/report/aged_partner_balance_xlsx.py:0 #: code:addons/account_financial_report/report/aged_partner_balance_xlsx.py:0 #, python-format -msgid "Age ??? 120 d." +msgid "Age ≤ 120 d." msgstr "" #. module: account_financial_report #: model_terms:ir.ui.view,arch_db:account_financial_report.report_aged_partner_balance_move_lines msgid "" -"Age ??? 30\n" -" d." +"Age ≤ 30\n" +" d." msgstr "" #. module: account_financial_report @@ -177,14 +194,14 @@ msgstr "" #: code:addons/account_financial_report/report/aged_partner_balance_xlsx.py:0 #: code:addons/account_financial_report/report/aged_partner_balance_xlsx.py:0 #, python-format -msgid "Age ??? 30 d." +msgid "Age ≤ 30 d." msgstr "" #. module: account_financial_report #: model_terms:ir.ui.view,arch_db:account_financial_report.report_aged_partner_balance_move_lines msgid "" -"Age ??? 60\n" -" d." +"Age ≤ 60\n" +" d." msgstr "" #. module: account_financial_report @@ -192,14 +209,14 @@ msgstr "" #: code:addons/account_financial_report/report/aged_partner_balance_xlsx.py:0 #: code:addons/account_financial_report/report/aged_partner_balance_xlsx.py:0 #, python-format -msgid "Age ??? 60 d." +msgid "Age ≤ 60 d." msgstr "" #. module: account_financial_report #: model_terms:ir.ui.view,arch_db:account_financial_report.report_aged_partner_balance_move_lines msgid "" -"Age ??? 90\n" -" d." +"Age ≤ 90\n" +" d." msgstr "" #. module: account_financial_report @@ -207,7 +224,7 @@ msgstr "" #: code:addons/account_financial_report/report/aged_partner_balance_xlsx.py:0 #: code:addons/account_financial_report/report/aged_partner_balance_xlsx.py:0 #, python-format -msgid "Age ??? 90 d." +msgid "Age ≤ 90 d." msgstr "" #. module: account_financial_report @@ -419,6 +436,7 @@ msgstr "" #. module: account_financial_report #. odoo-python #: code:addons/account_financial_report/report/journal_ledger_xlsx.py:0 +#: model:ir.model.fields,field_description:account_financial_report.field_account_age_report_configuration__company_id #: model:ir.model.fields,field_description:account_financial_report.field_account_financial_report_abstract_wizard__company_id #: model:ir.model.fields,field_description:account_financial_report.field_aged_partner_balance_report_wizard__company_id #: model:ir.model.fields,field_description:account_financial_report.field_general_ledger_report_wizard__company_id @@ -436,6 +454,18 @@ msgid "Compute accounts" msgstr "" #. module: account_financial_report +#: model:ir.model,name:account_financial_report.model_res_config_settings +msgid "Config Settings" +msgstr "" + +#. module: account_financial_report +#: model_terms:ir.ui.view,arch_db:account_financial_report.res_config_settings_view_form +msgid "Configurations" +msgstr "" + +#. module: account_financial_report +#: model:ir.model.fields,field_description:account_financial_report.field_account_age_report_configuration__create_uid +#: model:ir.model.fields,field_description:account_financial_report.field_account_age_report_configuration_line__create_uid #: model:ir.model.fields,field_description:account_financial_report.field_aged_partner_balance_report_wizard__create_uid #: model:ir.model.fields,field_description:account_financial_report.field_general_ledger_report_wizard__create_uid #: model:ir.model.fields,field_description:account_financial_report.field_journal_ledger_report_wizard__create_uid @@ -446,6 +476,8 @@ msgid "Created by" msgstr "" #. module: account_financial_report +#: model:ir.model.fields,field_description:account_financial_report.field_account_age_report_configuration__create_date +#: model:ir.model.fields,field_description:account_financial_report.field_account_age_report_configuration_line__create_date #: model:ir.model.fields,field_description:account_financial_report.field_aged_partner_balance_report_wizard__create_date #: model:ir.model.fields,field_description:account_financial_report.field_general_ledger_report_wizard__create_date #: model:ir.model.fields,field_description:account_financial_report.field_journal_ledger_report_wizard__create_date @@ -637,6 +669,8 @@ msgid "Detail Taxes" msgstr "" #. module: account_financial_report +#: model:ir.model.fields,field_description:account_financial_report.field_account_age_report_configuration__display_name +#: model:ir.model.fields,field_description:account_financial_report.field_account_age_report_configuration_line__display_name #: model:ir.model.fields,field_description:account_financial_report.field_aged_partner_balance_report_wizard__display_name #: model:ir.model.fields,field_description:account_financial_report.field_general_ledger_report_wizard__display_name #: model:ir.model.fields,field_description:account_financial_report.field_journal_ledger_report_wizard__display_name @@ -916,6 +950,12 @@ msgstr "" msgid "Grouped By" msgstr "" +#. module: account_financial_report +#: model_terms:ir.ui.view,arch_db:account_financial_report.res_config_settings_view_form +msgid "" +"Here you can set the intervals that will appear on the Aged Partner Balance." +msgstr "" + #. module: account_financial_report #. odoo-python #: code:addons/account_financial_report/report/general_ledger_xlsx.py:0 @@ -945,6 +985,8 @@ msgid "Hierarchy Levels to display" msgstr "" #. module: account_financial_report +#: model:ir.model.fields,field_description:account_financial_report.field_account_age_report_configuration__id +#: model:ir.model.fields,field_description:account_financial_report.field_account_age_report_configuration_line__id #: model:ir.model.fields,field_description:account_financial_report.field_aged_partner_balance_report_wizard__id #: model:ir.model.fields,field_description:account_financial_report.field_general_ledger_report_wizard__id #: model:ir.model.fields,field_description:account_financial_report.field_journal_ledger_report_wizard__id @@ -961,6 +1003,18 @@ msgid "" "webkit one only), only centralized amounts per period." msgstr "" +#. module: account_financial_report +#: model:ir.model.fields,field_description:account_financial_report.field_account_age_report_configuration_line__inferior_limit +msgid "Inferior Limit" +msgstr "" + +#. module: account_financial_report +#. odoo-python +#: code:addons/account_financial_report/models/account_age_report_configuration.py:0 +#, python-format +msgid "Inferior Limit must be greather than zero" +msgstr "" + #. module: account_financial_report #: model_terms:ir.ui.view,arch_db:account_financial_report.report_trial_balance_lines_header msgid "" @@ -987,6 +1041,12 @@ msgstr "" msgid "Initial balance" msgstr "" +#. module: account_financial_report +#: model:ir.model.fields,field_description:account_financial_report.field_aged_partner_balance_report_wizard__age_partner_config_id +#: model:ir.model.fields,field_description:account_financial_report.field_res_config_settings__default_age_partner_config_id +msgid "Intervals configuration" +msgstr "" + #. module: account_financial_report #. odoo-python #: code:addons/account_financial_report/report/aged_partner_balance_xlsx.py:0 @@ -1056,6 +1116,8 @@ msgid "Journals" msgstr "" #. module: account_financial_report +#: model:ir.model.fields,field_description:account_financial_report.field_account_age_report_configuration__write_uid +#: model:ir.model.fields,field_description:account_financial_report.field_account_age_report_configuration_line__write_uid #: model:ir.model.fields,field_description:account_financial_report.field_aged_partner_balance_report_wizard__write_uid #: model:ir.model.fields,field_description:account_financial_report.field_general_ledger_report_wizard__write_uid #: model:ir.model.fields,field_description:account_financial_report.field_journal_ledger_report_wizard__write_uid @@ -1066,6 +1128,8 @@ msgid "Last Updated by" msgstr "" #. module: account_financial_report +#: model:ir.model.fields,field_description:account_financial_report.field_account_age_report_configuration__write_date +#: model:ir.model.fields,field_description:account_financial_report.field_account_age_report_configuration_line__write_date #: model:ir.model.fields,field_description:account_financial_report.field_aged_partner_balance_report_wizard__write_date #: model:ir.model.fields,field_description:account_financial_report.field_general_ledger_report_wizard__write_date #: model:ir.model.fields,field_description:account_financial_report.field_journal_ledger_report_wizard__write_date @@ -1097,6 +1161,11 @@ msgstr "" msgid "Limit hierarchy levels" msgstr "" +#. module: account_financial_report +#: model:ir.model.fields,field_description:account_financial_report.field_account_age_report_configuration__line_ids +msgid "Line" +msgstr "" + #. module: account_financial_report #. odoo-python #: code:addons/account_financial_report/report/general_ledger.py:0 @@ -1108,6 +1177,16 @@ msgstr "" msgid "Missing Partner" msgstr "" +#. module: account_financial_report +#: model:ir.model,name:account_financial_report.model_account_age_report_configuration_line +msgid "Model to set interval lines for Age partner balance report" +msgstr "" + +#. module: account_financial_report +#: model:ir.model,name:account_financial_report.model_account_age_report_configuration +msgid "Model to set intervals for Age partner balance report" +msgstr "" + #. module: account_financial_report #: model:ir.model.fields,field_description:account_financial_report.field_journal_ledger_report_wizard__move_target msgid "Move Target" @@ -1118,10 +1197,19 @@ msgstr "" msgid "Moves" msgstr "" +#. module: account_financial_report +#. odoo-python +#: code:addons/account_financial_report/models/account_age_report_configuration.py:0 +#, python-format +msgid "Must complete Configuration Lines" +msgstr "" + #. module: account_financial_report #. odoo-python #: code:addons/account_financial_report/report/journal_ledger_xlsx.py:0 #: code:addons/account_financial_report/report/vat_report_xlsx.py:0 +#: model:ir.model.fields,field_description:account_financial_report.field_account_age_report_configuration__name +#: model:ir.model.fields,field_description:account_financial_report.field_account_age_report_configuration_line__name #: model_terms:ir.ui.view,arch_db:account_financial_report.report_journal_all_taxes #: model_terms:ir.ui.view,arch_db:account_financial_report.report_journal_ledger_journal_taxes #: model_terms:ir.ui.view,arch_db:account_financial_report.report_vat_report_base @@ -1129,6 +1217,13 @@ msgstr "" msgid "Name" msgstr "" +#. module: account_financial_report +#. odoo-python +#: code:addons/account_financial_report/models/account_age_report_configuration.py:0 +#, python-format +msgid "Name must be unique per report configuration" +msgstr "" + #. module: account_financial_report #. odoo-python #: code:addons/account_financial_report/report/vat_report_xlsx.py:0 @@ -1180,6 +1275,11 @@ msgstr "" msgid "Not due" msgstr "" +#. module: account_financial_report +#: model_terms:ir.ui.view,arch_db:account_financial_report.res_config_settings_view_form +msgid "OCA Aged Report Configuration" +msgstr "" + #. module: account_financial_report #: model:ir.ui.menu,name:account_financial_report.menu_oca_reports msgid "OCA accounting reports" diff --git a/account_financial_report/i18n/es.po b/account_financial_report/i18n/es.po index c5d74d15..b5df54cf 100644 --- a/account_financial_report/i18n/es.po +++ b/account_financial_report/i18n/es.po @@ -53,6 +53,11 @@ msgstr "91 - 120 d." msgid "Taxes summary" msgstr "Resumen de Impuestos" +#. module: account_financial_report +#: model_terms:ir.ui.view,arch_db:account_financial_report.res_config_settings_view_form +msgid "Intervals configuration" +msgstr "Configuración de intervalos" + #. module: account_financial_report #: model_terms:ir.ui.view,arch_db:account_financial_report.aged_partner_balance_wizard #: model_terms:ir.ui.view,arch_db:account_financial_report.general_ledger_wizard @@ -93,6 +98,11 @@ msgstr "Extracto XLSX Account Financial Report" msgid "Account" msgstr "Cuenta" +#. module: account_financial_report +#: model:ir.model.fields,field_description:account_financial_report.field_account_age_report_configuration_line__account_age_report_config_id +msgid "Account Age Report Config" +msgstr "Configuración del informe de calidad de deuda" + #. module: account_financial_report #: model:ir.model.fields,field_description:account_financial_report.field_aged_partner_balance_report_wizard__account_code_from #: model:ir.model.fields,field_description:account_financial_report.field_general_ledger_report_wizard__account_code_from @@ -427,6 +437,7 @@ msgstr "C??digo" #. module: account_financial_report #. odoo-python #: code:addons/account_financial_report/report/journal_ledger_xlsx.py:0 +#: model:ir.model.fields,field_description:account_financial_report.field_account_age_report_configuration__company_id #: model:ir.model.fields,field_description:account_financial_report.field_account_financial_report_abstract_wizard__company_id #: model:ir.model.fields,field_description:account_financial_report.field_aged_partner_balance_report_wizard__company_id #: model:ir.model.fields,field_description:account_financial_report.field_general_ledger_report_wizard__company_id @@ -444,6 +455,18 @@ msgid "Compute accounts" msgstr "Cuentas calculadas" #. module: account_financial_report +#: model:ir.model,name:account_financial_report.model_res_config_settings +msgid "Config Settings" +msgstr "Ajustes de configuración" + +#. module: account_financial_report +#: model_terms:ir.ui.view,arch_db:account_financial_report.res_config_settings_view_form +msgid "Configurations" +msgstr "Configuraciones" + +#. module: account_financial_report +#: model:ir.model.fields,field_description:account_financial_report.field_account_age_report_configuration__create_uid +#: model:ir.model.fields,field_description:account_financial_report.field_account_age_report_configuration_line__create_uid #: model:ir.model.fields,field_description:account_financial_report.field_aged_partner_balance_report_wizard__create_uid #: model:ir.model.fields,field_description:account_financial_report.field_general_ledger_report_wizard__create_uid #: model:ir.model.fields,field_description:account_financial_report.field_journal_ledger_report_wizard__create_uid @@ -454,6 +477,8 @@ msgid "Created by" msgstr "Creado por" #. module: account_financial_report +#: model:ir.model.fields,field_description:account_financial_report.field_account_age_report_configuration__create_date +#: model:ir.model.fields,field_description:account_financial_report.field_account_age_report_configuration_line__create_date #: model:ir.model.fields,field_description:account_financial_report.field_aged_partner_balance_report_wizard__create_date #: model:ir.model.fields,field_description:account_financial_report.field_general_ledger_report_wizard__create_date #: model:ir.model.fields,field_description:account_financial_report.field_journal_ledger_report_wizard__create_date @@ -468,6 +493,7 @@ msgstr "Creado el" #: code:addons/account_financial_report/report/general_ledger_xlsx.py:0 #: code:addons/account_financial_report/report/journal_ledger_xlsx.py:0 #: code:addons/account_financial_report/report/trial_balance_xlsx.py:0 +#: code:addons/account_financial_report/report/trial_balance_xlsx.py:0 #: model_terms:ir.ui.view,arch_db:account_financial_report.report_general_ledger_lines #: model_terms:ir.ui.view,arch_db:account_financial_report.report_journal_all_taxes #: model_terms:ir.ui.view,arch_db:account_financial_report.report_journal_ledger_journal_table_header @@ -528,6 +554,7 @@ msgstr "Moneda" #. module: account_financial_report #. odoo-python #: code:addons/account_financial_report/report/aged_partner_balance_xlsx.py:0 +#: code:addons/account_financial_report/report/aged_partner_balance_xlsx.py:0 #: model_terms:ir.ui.view,arch_db:account_financial_report.report_aged_partner_balance_move_lines #, python-format msgid "Current" @@ -618,6 +645,7 @@ msgstr "Hasta" #: code:addons/account_financial_report/report/general_ledger_xlsx.py:0 #: code:addons/account_financial_report/report/journal_ledger_xlsx.py:0 #: code:addons/account_financial_report/report/trial_balance_xlsx.py:0 +#: code:addons/account_financial_report/report/trial_balance_xlsx.py:0 #: model_terms:ir.ui.view,arch_db:account_financial_report.report_general_ledger_lines #: model_terms:ir.ui.view,arch_db:account_financial_report.report_journal_all_taxes #: model_terms:ir.ui.view,arch_db:account_financial_report.report_journal_ledger_journal_table_header @@ -642,6 +670,8 @@ msgid "Detail Taxes" msgstr "Detalle de impuestos" #. module: account_financial_report +#: model:ir.model.fields,field_description:account_financial_report.field_account_age_report_configuration__display_name +#: model:ir.model.fields,field_description:account_financial_report.field_account_age_report_configuration_line__display_name #: model:ir.model.fields,field_description:account_financial_report.field_aged_partner_balance_report_wizard__display_name #: model:ir.model.fields,field_description:account_financial_report.field_general_ledger_report_wizard__display_name #: model:ir.model.fields,field_description:account_financial_report.field_journal_ledger_report_wizard__display_name @@ -727,6 +757,9 @@ msgstr "Cuenta final en un rango" #: code:addons/account_financial_report/report/general_ledger_xlsx.py:0 #: code:addons/account_financial_report/report/open_items_xlsx.py:0 #: code:addons/account_financial_report/report/trial_balance_xlsx.py:0 +#: code:addons/account_financial_report/report/trial_balance_xlsx.py:0 +#: code:addons/account_financial_report/report/trial_balance_xlsx.py:0 +#: code:addons/account_financial_report/report/trial_balance_xlsx.py:0 #: model_terms:ir.ui.view,arch_db:account_financial_report.report_general_ledger_ending_cumul #: model_terms:ir.ui.view,arch_db:account_financial_report.report_trial_balance_lines_header #, python-format @@ -773,6 +806,7 @@ msgstr "N??mero de asiento" #. module: account_financial_report #. odoo-javascript #: code:addons/account_financial_report/static/src/xml/report.xml:0 +#: code:addons/account_financial_report/static/src/xml/report.xml:0 #, python-format msgid "Export" msgstr "Exportar" @@ -918,8 +952,7 @@ msgid "" " only one unaffected earnings account." msgstr "" "El Libro mayor solo se puede calcular si la empresa seleccionada tiene \n" -" solo una cuenta " -"de resultados no afectados." +" solo una cuenta de resultados no afectados." #. module: account_financial_report #: model:ir.model.fields,field_description:account_financial_report.field_journal_ledger_report_wizard__group_option @@ -931,6 +964,12 @@ msgstr "Agrupar por" msgid "Grouped By" msgstr "Agrupado por" +#. module: account_financial_report +#: model_terms:ir.ui.view,arch_db:account_financial_report.res_config_settings_view_form +msgid "" +"Here you can set the intervals that will appear on the Aged Partner Balance." +msgstr "Aquí puede configurar los intervalos que aparecerán en el informe de Calidad de la deuda." + #. module: account_financial_report #. odoo-python #: code:addons/account_financial_report/report/general_ledger_xlsx.py:0 @@ -960,6 +999,8 @@ msgid "Hierarchy Levels to display" msgstr "Niveles de Jerarqu??a a mostrar" #. module: account_financial_report +#: model:ir.model.fields,field_description:account_financial_report.field_account_age_report_configuration__id +#: model:ir.model.fields,field_description:account_financial_report.field_account_age_report_configuration_line__id #: model:ir.model.fields,field_description:account_financial_report.field_aged_partner_balance_report_wizard__id #: model:ir.model.fields,field_description:account_financial_report.field_general_ledger_report_wizard__id #: model:ir.model.fields,field_description:account_financial_report.field_journal_ledger_report_wizard__id @@ -978,6 +1019,18 @@ msgstr "" "Si se marca, no se mostrar??n detalles en el informe del libro mayor (solo " "el webkit), solo importes centralizados por per??odo." +#. module: account_financial_report +#: model:ir.model.fields,field_description:account_financial_report.field_account_age_report_configuration_line__inferior_limit +msgid "Inferior Limit" +msgstr "Límite inferior" + +#. module: account_financial_report +#. odoo-python +#: code:addons/account_financial_report/models/account_age_report_configuration.py:0 +#, python-format +msgid "Inferior Limit must be greather than zero" +msgstr "El límite inferior debe ser mayor que cero" + #. module: account_financial_report #: model_terms:ir.ui.view,arch_db:account_financial_report.report_trial_balance_lines_header msgid "" @@ -1000,11 +1053,20 @@ msgstr "" #. odoo-python #: code:addons/account_financial_report/report/general_ledger_xlsx.py:0 #: code:addons/account_financial_report/report/trial_balance_xlsx.py:0 +#: code:addons/account_financial_report/report/trial_balance_xlsx.py:0 +#: code:addons/account_financial_report/report/trial_balance_xlsx.py:0 +#: code:addons/account_financial_report/report/trial_balance_xlsx.py:0 #: model_terms:ir.ui.view,arch_db:account_financial_report.report_general_ledger_lines #, python-format msgid "Initial balance" msgstr "Saldo inicial" +#. module: account_financial_report +#: model:ir.model.fields,field_description:account_financial_report.field_aged_partner_balance_report_wizard__age_partner_config_id +#: model:ir.model.fields,field_description:account_financial_report.field_res_config_settings__default_age_partner_config_id +msgid "Intervals configuration" +msgstr "Configuración de intervalos" + #. module: account_financial_report #. odoo-python #: code:addons/account_financial_report/report/aged_partner_balance_xlsx.py:0 @@ -1074,6 +1136,8 @@ msgid "Journals" msgstr "Diarios" #. module: account_financial_report +#: model:ir.model.fields,field_description:account_financial_report.field_account_age_report_configuration__write_uid +#: model:ir.model.fields,field_description:account_financial_report.field_account_age_report_configuration_line__write_uid #: model:ir.model.fields,field_description:account_financial_report.field_aged_partner_balance_report_wizard__write_uid #: model:ir.model.fields,field_description:account_financial_report.field_general_ledger_report_wizard__write_uid #: model:ir.model.fields,field_description:account_financial_report.field_journal_ledger_report_wizard__write_uid @@ -1084,6 +1148,8 @@ msgid "Last Updated by" msgstr "??ltima actualizaci??n por" #. module: account_financial_report +#: model:ir.model.fields,field_description:account_financial_report.field_account_age_report_configuration__write_date +#: model:ir.model.fields,field_description:account_financial_report.field_account_age_report_configuration_line__write_date #: model:ir.model.fields,field_description:account_financial_report.field_aged_partner_balance_report_wizard__write_date #: model:ir.model.fields,field_description:account_financial_report.field_general_ledger_report_wizard__write_date #: model:ir.model.fields,field_description:account_financial_report.field_journal_ledger_report_wizard__write_date @@ -1115,15 +1181,32 @@ msgstr "Nivel %s" msgid "Limit hierarchy levels" msgstr "Limitar niveles de jerarqu??a" +#. module: account_financial_report +#: model:ir.model.fields,field_description:account_financial_report.field_account_age_report_configuration__line_ids +msgid "Line" +msgstr "Línea" + #. module: account_financial_report #. odoo-python #: code:addons/account_financial_report/report/general_ledger.py:0 +#: code:addons/account_financial_report/report/general_ledger.py:0 #: code:addons/account_financial_report/report/open_items.py:0 #: code:addons/account_financial_report/report/trial_balance.py:0 +#: code:addons/account_financial_report/report/trial_balance.py:0 #, python-format msgid "Missing Partner" msgstr "" +#. module: account_financial_report +#: model:ir.model,name:account_financial_report.model_account_age_report_configuration_line +msgid "Model to set interval lines for Age partner balance report" +msgstr "Modelo para establecer líneas de intervalo para el informe de Calidad de deuda" + +#. module: account_financial_report +#: model:ir.model,name:account_financial_report.model_account_age_report_configuration +msgid "Model to set intervals for Age partner balance report" +msgstr "Modelo para establecer intervalos en el informe de Calidad de deuda" + #. module: account_financial_report #: model:ir.model.fields,field_description:account_financial_report.field_journal_ledger_report_wizard__move_target msgid "Move Target" @@ -1134,10 +1217,19 @@ msgstr "Asiento Objetivo" msgid "Moves" msgstr "Asientos" +#. module: account_financial_report +#. odoo-python +#: code:addons/account_financial_report/models/account_age_report_configuration.py:0 +#, python-format +msgid "Must complete Configuration Lines" +msgstr "Debe completar las líneas de configuración" + #. module: account_financial_report #. odoo-python #: code:addons/account_financial_report/report/journal_ledger_xlsx.py:0 #: code:addons/account_financial_report/report/vat_report_xlsx.py:0 +#: model:ir.model.fields,field_description:account_financial_report.field_account_age_report_configuration__name +#: model:ir.model.fields,field_description:account_financial_report.field_account_age_report_configuration_line__name #: model_terms:ir.ui.view,arch_db:account_financial_report.report_journal_all_taxes #: model_terms:ir.ui.view,arch_db:account_financial_report.report_journal_ledger_journal_taxes #: model_terms:ir.ui.view,arch_db:account_financial_report.report_vat_report_base @@ -1145,6 +1237,13 @@ msgstr "Asientos" msgid "Name" msgstr "Nombre" +#. module: account_financial_report +#. odoo-python +#: code:addons/account_financial_report/models/account_age_report_configuration.py:0 +#, python-format +msgid "Name must be unique per report configuration" +msgstr "El nombre debe ser único por cada configuración del informe" + #. module: account_financial_report #. odoo-python #: code:addons/account_financial_report/report/vat_report_xlsx.py:0 @@ -1195,6 +1294,11 @@ msgstr "Sin Postear" msgid "Not due" msgstr "Deuda" +#. module: account_financial_report +#: model_terms:ir.ui.view,arch_db:account_financial_report.res_config_settings_view_form +msgid "OCA Aged Report Configuration" +msgstr "Configuración del informe Calidad de deuda OCA" + #. module: account_financial_report #: model:ir.ui.menu,name:account_financial_report.menu_oca_reports msgid "OCA accounting reports" @@ -1203,6 +1307,7 @@ msgstr "Informes de contabilidad OCA" #. module: account_financial_report #. odoo-python #: code:addons/account_financial_report/report/aged_partner_balance_xlsx.py:0 +#: code:addons/account_financial_report/report/aged_partner_balance_xlsx.py:0 #: model_terms:ir.ui.view,arch_db:account_financial_report.report_aged_partner_balance_move_lines #, python-format msgid "Older" @@ -1271,6 +1376,7 @@ msgstr "Inicial" #. module: account_financial_report #. odoo-python #: code:addons/account_financial_report/report/aged_partner_balance_xlsx.py:0 +#: code:addons/account_financial_report/report/aged_partner_balance_xlsx.py:0 #: code:addons/account_financial_report/report/general_ledger_xlsx.py:0 #: code:addons/account_financial_report/report/journal_ledger_xlsx.py:0 #: code:addons/account_financial_report/report/open_items_xlsx.py:0 @@ -1344,6 +1450,7 @@ msgstr "Porcentajes" #. module: account_financial_report #. odoo-python #: code:addons/account_financial_report/report/trial_balance_xlsx.py:0 +#: code:addons/account_financial_report/report/trial_balance_xlsx.py:0 #: model_terms:ir.ui.view,arch_db:account_financial_report.report_trial_balance_lines_header #, python-format msgid "Period balance" @@ -1410,11 +1517,12 @@ msgstr "Ref - Etiqueta" #. module: account_financial_report #: model:ir.model,name:account_financial_report.model_ir_actions_report msgid "Report Action" -msgstr "Acci??n Informe" +msgstr "Acción de informe" #. module: account_financial_report #. odoo-python #: code:addons/account_financial_report/report/aged_partner_balance_xlsx.py:0 +#: code:addons/account_financial_report/report/aged_partner_balance_xlsx.py:0 #: code:addons/account_financial_report/report/open_items_xlsx.py:0 #: model_terms:ir.ui.view,arch_db:account_financial_report.report_aged_partner_balance_lines_header #: model_terms:ir.ui.view,arch_db:account_financial_report.report_aged_partner_balance_move_lines @@ -1817,6 +1925,7 @@ msgstr "Cuenta con Nombre" #. module: account_financial_report #. odoo-python #: code:addons/account_financial_report/report/general_ledger_xlsx.py:0 +#: code:addons/account_financial_report/report/general_ledger_xlsx.py:0 #: code:addons/account_financial_report/report/open_items_xlsx.py:0 #: code:addons/account_financial_report/report/trial_balance_xlsx.py:0 #: model_terms:ir.ui.view,arch_db:account_financial_report.report_general_ledger_filters diff --git a/account_financial_report/models/__init__.py b/account_financial_report/models/__init__.py index afbe6974..154d80e3 100644 --- a/account_financial_report/models/__init__.py +++ b/account_financial_report/models/__init__.py @@ -1,4 +1,6 @@ +from . import account_age_report_configuration from . import account_group from . import account from . import account_move_line from . import ir_actions_report +from . import res_config_settings diff --git a/account_financial_report/models/account_age_report_configuration.py b/account_financial_report/models/account_age_report_configuration.py new file mode 100644 index 00000000..9d69d5a1 --- /dev/null +++ b/account_financial_report/models/account_age_report_configuration.py @@ -0,0 +1,47 @@ +# Copyright 2023 Ernesto García +# Copyright 2023 Carolina Fernandez +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import _, api, fields, models +from odoo.exceptions import ValidationError + + +class AccountAgeReportConfiguration(models.Model): + _name = "account.age.report.configuration" + _description = "Model to set intervals for Age partner balance report" + + name = fields.Char(required=True) + company_id = fields.Many2one( + "res.company", default=lambda self: self.env.company, readonly=True + ) + line_ids = fields.One2many( + "account.age.report.configuration.line", "account_age_report_config_id" + ) + + @api.constrains("line_ids") + def _check_line_ids(self): + for rec in self: + if not rec.line_ids: + raise ValidationError(_("Must complete Configuration Lines")) + + +class AccountAgeReportConfigurationLine(models.Model): + _name = "account.age.report.configuration.line" + _description = "Model to set interval lines for Age partner balance report" + + name = fields.Char(required=True) + account_age_report_config_id = fields.Many2one("account.age.report.configuration") + inferior_limit = fields.Integer() + + @api.constrains("inferior_limit") + def _check_inferior_limit(self): + for rec in self: + if rec.inferior_limit <= 0: + raise ValidationError(_("Inferior Limit must be greather than zero")) + + _sql_constraints = [ + ( + "unique_name_config_combination", + "UNIQUE(name,account_age_report_config_id)", + _("Name must be unique per report configuration"), + ) + ] diff --git a/account_financial_report/models/res_config_settings.py b/account_financial_report/models/res_config_settings.py new file mode 100644 index 00000000..56826b0e --- /dev/null +++ b/account_financial_report/models/res_config_settings.py @@ -0,0 +1,14 @@ +# Copyright 2023 Tecnativa - Carolina Fernandez +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). + +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + _inherit = "res.config.settings" + + default_age_partner_config_id = fields.Many2one( + "account.age.report.configuration", + string="Intervals configuration", + default_model="aged.partner.balance.report.wizard", + ) diff --git a/account_financial_report/readme/CONFIGURE.md b/account_financial_report/readme/CONFIGURE.md new file mode 100644 index 00000000..74205bfd --- /dev/null +++ b/account_financial_report/readme/CONFIGURE.md @@ -0,0 +1,26 @@ +To configure dynamic intervals for Aged Partner Balance you need to: + +Go on 'Settings' -> 'Invoicing' -> 'OCA Aged Report Configuration'. + +Click on option 'Configurations' and create new record. + +Create new interval. +The name established on line will be the column to display in Aged Partner Balance. +Inferior limit established on line is the interval + +Example of configuration inferior limit: + +-> 15 +-> 30 +-> 60 + +It means the first interval is from 0 to 15, the second from 16 to 30, and the third is 61+. + +Go on 'Invoicing' -> 'Reports' -> 'OCA accounting reports' -> 'Aged Partner Balance' + +When wizard is open, you need to select your interval configuration and print report. + +If you want to get default interval configuration any time you wish to print Aged Partner Report, +you can set default interval configuration per company in: + +'Settings' -> 'Invoicing' -> 'OCA Aged Report Configuration'. diff --git a/account_financial_report/readme/CONTRIBUTORS.md b/account_financial_report/readme/CONTRIBUTORS.md index f1576593..e305417e 100644 --- a/account_financial_report/readme/CONTRIBUTORS.md +++ b/account_financial_report/readme/CONTRIBUTORS.md @@ -23,6 +23,7 @@ - Jo??o Marques - Alexandre D. D??az - V??ctor Mart??nez + - Carolina Fernandez - [Sygel](https://www.sygel.es): - Harald Panten - Valentin Vinagre diff --git a/account_financial_report/readme/DESCRIPTION.md b/account_financial_report/readme/DESCRIPTION.md index 5a6e7173..948ed38a 100644 --- a/account_financial_report/readme/DESCRIPTION.md +++ b/account_financial_report/readme/DESCRIPTION.md @@ -15,3 +15,7 @@ properly shown. In case that in an account has not been configured a second currency foreign currency balances are not available. + +Invoicing / Settings / Invoicing / OCA Aged Report Configuration you will be able to set +dynamic intervals that will appear on the Aged Partner Balance. +For further information, check CONFIGURE.rst diff --git a/account_financial_report/report/aged_partner_balance.py b/account_financial_report/report/aged_partner_balance.py index 16737f18..d6bf09bf 100644 --- a/account_financial_report/report/aged_partner_balance.py +++ b/account_financial_report/report/aged_partner_balance.py @@ -25,6 +25,8 @@ class AgedPartnerBalanceReport(models.AbstractModel): ag_pb_data[acc_id]["90_days"] = 0.0 ag_pb_data[acc_id]["120_days"] = 0.0 ag_pb_data[acc_id]["older"] = 0.0 + for interval_line in self.env.context["age_partner_config"].line_ids: + ag_pb_data[acc_id][interval_line] = 0.0 return ag_pb_data @api.model @@ -39,6 +41,8 @@ class AgedPartnerBalanceReport(models.AbstractModel): ag_pb_data[acc_id][prt_id]["120_days"] = 0.0 ag_pb_data[acc_id][prt_id]["older"] = 0.0 ag_pb_data[acc_id][prt_id]["move_lines"] = [] + for interval_line in self.env.context["age_partner_config"].line_ids: + ag_pb_data[acc_id][prt_id][interval_line] = 0.0 return ag_pb_data @api.model @@ -47,6 +51,7 @@ class AgedPartnerBalanceReport(models.AbstractModel): ): ag_pb_data[acc_id]["residual"] += residual ag_pb_data[acc_id][prt_id]["residual"] += residual + interval_lines = self.env.context["age_partner_config"].line_ids today = date_at_object if not due_date or today <= due_date: ag_pb_data[acc_id]["current"] += residual @@ -66,8 +71,34 @@ class AgedPartnerBalanceReport(models.AbstractModel): else: ag_pb_data[acc_id]["older"] += residual ag_pb_data[acc_id][prt_id]["older"] += residual + if due_date: + days_difference = abs((today - due_date).days) + for index, line in enumerate(interval_lines): + lower_limit = ( + 0 if not index else interval_lines[index - 1].inferior_limit + ) + next_line = ( + interval_lines[index] if index < len(interval_lines) else None + ) + interval_range = self._get_values_for_range_intervals( + lower_limit, next_line.inferior_limit + ) + if ( + days_difference in interval_range + or days_difference == line.inferior_limit + ): + ag_pb_data[acc_id][line] += residual + ag_pb_data[acc_id][prt_id][line] += residual + break return ag_pb_data + def _get_values_for_range_intervals(self, num1, num2): + min_num = min(num1, num2) + max_num = max(num1, num2) + if abs(num2 - num1) == 1: + return [max_num] + return list(range(min_num + 1, max_num)) + def _get_account_partial_reconciled(self, company_id, date_at_object): domain = [("max_date", ">", date_at_object), ("company_id", "=", company_id)] fields = [ @@ -235,6 +266,9 @@ class AgedPartnerBalanceReport(models.AbstractModel): "older": 0.0, } ) + interval_lines = self.env.context["age_partner_config"].line_ids + for interval_line in interval_lines: + ml[interval_line] = 0.0 due_date = ml["due_date"] amount = ml["residual"] today = date_at_object @@ -250,6 +284,24 @@ class AgedPartnerBalanceReport(models.AbstractModel): ml["120_days"] += amount else: ml["older"] += amount + if due_date: + days_difference = abs((today - due_date).days) + for index, interval_line in enumerate(interval_lines): + lower_limit = ( + 0 if not index else interval_lines[index - 1].inferior_limit + ) + next_line = ( + interval_lines[index] if index < len(interval_lines) else None + ) + interval_range = self._get_values_for_range_intervals( + lower_limit, next_line.inferior_limit + ) + if ( + days_difference in interval_range + or days_difference == interval_line.inferior_limit + ): + ml[interval_line] += amount + break def _create_account_list( self, @@ -261,6 +313,7 @@ class AgedPartnerBalanceReport(models.AbstractModel): date_at_oject, ): aged_partner_data = [] + interval_lines = self.env.context["age_partner_config"].line_ids for account in accounts_data.values(): acc_id = account["id"] account.update( @@ -275,6 +328,8 @@ class AgedPartnerBalanceReport(models.AbstractModel): "partners": [], } ) + for interval_line in interval_lines: + account[interval_line] = ag_pb_data[acc_id][interval_line] for prt_id in ag_pb_data[acc_id]: if isinstance(prt_id, int): partner = { @@ -287,6 +342,10 @@ class AgedPartnerBalanceReport(models.AbstractModel): "120_days": ag_pb_data[acc_id][prt_id]["120_days"], "older": ag_pb_data[acc_id][prt_id]["older"], } + for interval_line in interval_lines: + partner[interval_line] = ag_pb_data[acc_id][prt_id][ + interval_line + ] if show_move_line_details: move_lines = [] for ml in ag_pb_data[acc_id][prt_id]["move_lines"]: @@ -306,6 +365,7 @@ class AgedPartnerBalanceReport(models.AbstractModel): @api.model def _calculate_percent(self, aged_partner_data): + interval_lines = self.env.context["age_partner_config"].line_ids for account in aged_partner_data: if abs(account["residual"]) > 0.01: total = account["residual"] @@ -331,6 +391,10 @@ class AgedPartnerBalanceReport(models.AbstractModel): ), } ) + for interval_line in interval_lines: + account[f"percent_{interval_line.id}"] = abs( + round((account[interval_line] / total) * 100, 2) + ) else: account.update( { @@ -342,6 +406,8 @@ class AgedPartnerBalanceReport(models.AbstractModel): "percent_older": 0.0, } ) + for interval_line in interval_lines: + account[f"percent_{interval_line.id}"] = 0.0 return aged_partner_data def _get_report_values(self, docids, data): @@ -355,12 +421,17 @@ class AgedPartnerBalanceReport(models.AbstractModel): date_from = data["date_from"] only_posted_moves = data["only_posted_moves"] show_move_line_details = data["show_move_line_details"] + aged_partner_configuration = self.env[ + "account.age.report.configuration" + ].browse(data["age_partner_config_id"]) ( ag_pb_data, accounts_data, partners_data, journals_data, - ) = self._get_move_lines_data( + ) = self.with_context( + age_partner_config=aged_partner_configuration + )._get_move_lines_data( company_id, account_ids, partner_ids, @@ -369,7 +440,9 @@ class AgedPartnerBalanceReport(models.AbstractModel): only_posted_moves, show_move_line_details, ) - aged_partner_data = self._create_account_list( + aged_partner_data = self.with_context( + age_partner_config=aged_partner_configuration + )._create_account_list( ag_pb_data, accounts_data, partners_data, @@ -377,7 +450,9 @@ class AgedPartnerBalanceReport(models.AbstractModel): show_move_line_details, date_at_object, ) - aged_partner_data = self._calculate_percent(aged_partner_data) + aged_partner_data = self.with_context( + age_partner_config=aged_partner_configuration + )._calculate_percent(aged_partner_data) return { "doc_ids": [wizard_id], "doc_model": "open.items.report.wizard", @@ -388,6 +463,7 @@ class AgedPartnerBalanceReport(models.AbstractModel): "only_posted_moves": only_posted_moves, "aged_partner_balance": aged_partner_data, "show_move_lines_details": show_move_line_details, + "age_partner_config": aged_partner_configuration, } def _get_ml_fields(self): diff --git a/account_financial_report/report/aged_partner_balance_xlsx.py b/account_financial_report/report/aged_partner_balance_xlsx.py index b87a7a1e..c6e44c83 100644 --- a/account_financial_report/report/aged_partner_balance_xlsx.py +++ b/account_financial_report/report/aged_partner_balance_xlsx.py @@ -20,67 +20,84 @@ class AgedPartnerBalanceXslx(models.AbstractModel): report_name = report_name + suffix return report_name - def _get_report_columns(self, report): - if not report.show_move_line_details: - return { - 0: {"header": _("Partner"), "field": "name", "width": 70}, - 1: { - "header": _("Residual"), - "field": "residual", - "field_footer_total": "residual", - "type": "amount", - "width": 14, - }, - 2: { - "header": _("Current"), - "field": "current", - "field_footer_total": "current", - "field_footer_percent": "percent_current", - "type": "amount", - "width": 14, - }, - 3: { - "header": _("Age ??? 30 d."), - "field": "30_days", - "field_footer_total": "30_days", - "field_footer_percent": "percent_30_days", - "type": "amount", - "width": 14, - }, - 4: { - "header": _("Age ??? 60 d."), - "field": "60_days", - "field_footer_total": "60_days", - "field_footer_percent": "percent_60_days", - "type": "amount", - "width": 14, - }, - 5: { - "header": _("Age ??? 90 d."), - "field": "90_days", - "field_footer_total": "90_days", - "field_footer_percent": "percent_90_days", - "type": "amount", - "width": 14, - }, - 6: { - "header": _("Age ??? 120 d."), - "field": "120_days", - "field_footer_total": "120_days", - "field_footer_percent": "percent_120_days", - "type": "amount", - "width": 14, - }, - 7: { - "header": _("Older"), - "field": "older", - "field_footer_total": "older", - "field_footer_percent": "percent_older", - "type": "amount", - "width": 14, - }, + def _get_report_columns_without_move_line_details(self, report, column_index): + report_columns = { + 0: {"header": _("Partner"), "field": "name", "width": 70}, + 1: { + "header": _("Residual"), + "field": "residual", + "field_footer_total": "residual", + "type": "amount", + "width": 14, + }, + 2: { + "header": _("Current"), + "field": "current", + "field_footer_total": "current", + "field_footer_percent": "percent_current", + "type": "amount", + "width": 14, + }, + } + if not report.age_partner_config_id: + report_columns.update( + { + 3: { + "header": _("Age ≤ 30 d."), + "field": "30_days", + "field_footer_total": "30_days", + "field_footer_percent": "percent_30_days", + "type": "amount", + "width": 14, + }, + 4: { + "header": _("Age ≤ 60 d."), + "field": "60_days", + "field_footer_total": "60_days", + "field_footer_percent": "percent_60_days", + "type": "amount", + "width": 14, + }, + 5: { + "header": _("Age ≤ 90 d."), + "field": "90_days", + "field_footer_total": "90_days", + "field_footer_percent": "percent_90_days", + "type": "amount", + "width": 14, + }, + 6: { + "header": _("Age ≤ 120 d."), + "field": "120_days", + "field_footer_total": "120_days", + "field_footer_percent": "percent_120_days", + "type": "amount", + "width": 14, + }, + 7: { + "header": _("Older"), + "field": "older", + "field_footer_total": "older", + "field_footer_percent": "percent_older", + "type": "amount", + "width": 14, + }, + } + ) + for interval in report.age_partner_config_id.line_ids: + report_columns[column_index] = { + "header": interval.name, + "field": interval, + "field_footer_total": interval, + "field_footer_percent": f"percent_{interval.id}", + "type": "amount", + "width": 14, } - return { + column_index += 1 + return report_columns + + def _get_report_columns_with_move_line_details(self, report, column_index): + report_columns = { 0: {"header": _("Date"), "field": "date", "width": 11}, 1: {"header": _("Entry"), "field": "entry", "width": 18}, 2: {"header": _("Journal"), "field": "journal", "width": 8}, @@ -105,52 +122,75 @@ class AgedPartnerBalanceXslx(models.AbstractModel): "type": "amount", "width": 14, }, - 9: { - "header": _("Age ??? 30 d."), - "field": "30_days", - "field_footer_total": "30_days", - "field_footer_percent": "percent_30_days", - "field_final_balance": "30_days", - "type": "amount", - "width": 14, - }, - 10: { - "header": _("Age ??? 60 d."), - "field": "60_days", - "field_footer_total": "60_days", - "field_footer_percent": "percent_60_days", - "field_final_balance": "60_days", - "type": "amount", - "width": 14, - }, - 11: { - "header": _("Age ??? 90 d."), - "field": "90_days", - "field_footer_total": "90_days", - "field_footer_percent": "percent_90_days", - "field_final_balance": "90_days", - "type": "amount", - "width": 14, - }, - 12: { - "header": _("Age ??? 120 d."), - "field": "120_days", - "field_footer_total": "120_days", - "field_footer_percent": "percent_120_days", - "field_final_balance": "120_days", - "type": "amount", - "width": 14, - }, - 13: { - "header": _("Older"), - "field": "older", - "field_footer_total": "older", - "field_footer_percent": "percent_older", - "field_final_balance": "older", - "type": "amount", - "width": 14, - }, } + if not report.age_partner_config_id: + report_columns.update( + { + 9: { + "header": _("Age ≤ 30 d."), + "field": "30_days", + "field_footer_total": "30_days", + "field_footer_percent": "percent_30_days", + "field_final_balance": "30_days", + "type": "amount", + "width": 14, + }, + 10: { + "header": _("Age ≤ 60 d."), + "field": "60_days", + "field_footer_total": "60_days", + "field_footer_percent": "percent_60_days", + "field_final_balance": "60_days", + "type": "amount", + "width": 14, + }, + 11: { + "header": _("Age ≤ 90 d."), + "field": "90_days", + "field_footer_total": "90_days", + "field_footer_percent": "percent_90_days", + "field_final_balance": "90_days", + "type": "amount", + "width": 14, + }, + 12: { + "header": _("Age ≤ 120 d."), + "field": "120_days", + "field_footer_total": "120_days", + "field_footer_percent": "percent_120_days", + "field_final_balance": "120_days", + "type": "amount", + "width": 14, + }, + 13: { + "header": _("Older"), + "field": "older", + "field_footer_total": "older", + "field_footer_percent": "percent_older", + "field_final_balance": "older", + "type": "amount", + "width": 14, + }, + } + ) + for interval in report.age_partner_config_id.line_ids: + report_columns[column_index] = { + "header": interval.name, + "field": interval, + "field_footer_total": interval, + "field_footer_percent": f"percent_{interval.id}", + "type": "amount", + "width": 14, + } + column_index += 1 + return report_columns + + def _get_report_columns(self, report): + if not report.show_move_line_details: + return self._get_report_columns_without_move_line_details( + report, column_index=3 + ) + return self._get_report_columns_with_move_line_details(report, column_index=9) def _get_report_filters(self, report): return [ diff --git a/account_financial_report/report/templates/aged_partner_balance.xml b/account_financial_report/report/templates/aged_partner_balance.xml index 800e5bf5..5eb70c78 100644 --- a/account_financial_report/report/templates/aged_partner_balance.xml +++ b/account_financial_report/report/templates/aged_partner_balance.xml @@ -116,16 +116,22 @@
Residual
Not due
- -
1 - 30 d.
- -
31 - 60 d.
- -
61 - 90 d.
- -
91 - 120 d.
- -
> 120 d.
+ + +
1 - 30 d.
+ +
31 - 60 d.
+ +
61 - 90 d.
+ +
91 - 120 d.
+ +
> 120 d.
+
+ + +
+
@@ -143,48 +149,58 @@ t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}" /> - +
-
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
+ + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+
+ +
+ +
+
@@ -534,48 +591,58 @@ t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}" /> - -
- +
+ -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
+
+ + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+
+ +
+ +
+
@@ -589,48 +656,58 @@ t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}" /> - -
- +
+ -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
+
+ + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+
+ +
+ +
+
@@ -642,33 +719,42 @@
- % -
- -
- - % -
- -
- - % -
- -
- - % -
- -
- - % -
- -
- - % -
+ % +
+ + +
+ + % +
+ +
+ + % +
+ +
+ + % +
+ +
+ + % +
+ +
+ + % +
+
+ + +
+ + % +
+
@@ -680,34 +766,43 @@
- % -
- -
- - % -
- -
- - % -
- -
- - % -
- -
- - % -
- -
- - % -
-
+ % + + + +
+ + % +
+ +
+ + % +
+ +
+ + % +
+ +
+ + % +
+ +
+ + % +
+
+ + +
+ + % +
+
+ diff --git a/account_financial_report/security/ir.model.access.csv b/account_financial_report/security/ir.model.access.csv index 9416c699..eed18285 100644 --- a/account_financial_report/security/ir.model.access.csv +++ b/account_financial_report/security/ir.model.access.csv @@ -5,3 +5,5 @@ access_journal_ledger_report_wizard,access_journal_ledger_report_wizard,model_jo access_open_items_report_wizard,access_open_items_report_wizard,model_open_items_report_wizard,base.group_user,1,1,1,1 access_trial_balance_report_wizard,access_trial_balance_report_wizard,model_trial_balance_report_wizard,base.group_user,1,1,1,1 access_vat_report_wizard,access_vat_report_wizard,model_vat_report_wizard,base.group_user,1,1,1,1 +access_account_age_report_configuration,access_account_age_report_configuration,model_account_age_report_configuration,base.group_user,1,1,1,1 +access_account_age_report_configuration_line,access_account_age_report_configuration_line,model_account_age_report_configuration_line,base.group_user,1,1,1,1 diff --git a/account_financial_report/security/security.xml b/account_financial_report/security/security.xml new file mode 100644 index 00000000..33fca13b --- /dev/null +++ b/account_financial_report/security/security.xml @@ -0,0 +1,8 @@ + + + + Account age report configuration rule + + [('company_id', 'in', company_ids + [False])] + + diff --git a/account_financial_report/tests/__init__.py b/account_financial_report/tests/__init__.py index f3c5e19c..34f4fdb9 100644 --- a/account_financial_report/tests/__init__.py +++ b/account_financial_report/tests/__init__.py @@ -7,3 +7,4 @@ from . import test_journal_ledger from . import test_open_items from . import test_trial_balance from . import test_vat_report +from . import test_age_report_configuration diff --git a/account_financial_report/tests/test_age_report_configuration.py b/account_financial_report/tests/test_age_report_configuration.py new file mode 100644 index 00000000..4142e1ea --- /dev/null +++ b/account_financial_report/tests/test_age_report_configuration.py @@ -0,0 +1,42 @@ +# Copyright 2023 Tecnativa - Carolina Fernandez +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo.exceptions import ValidationError +from odoo.tests import common, tagged + + +@tagged("post_install", "-at_install") +class TestAccountAgeReportConfiguration(common.TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.account_age_report_config = cls.env[ + "account.age.report.configuration" + ].create( + { + "name": "Intervals configuration", + "line_ids": [ + ( + 0, + 0, + { + "name": "1-30", + "inferior_limit": 30, + }, + ), + ], + } + ) + + def test_check_line_ids_constraint(self): + with self.assertRaises(ValidationError): + self.env["account.age.report.configuration"].create( + {"name": "Interval configuration", "line_ids": False} + ) + + def test_check_lower_inferior_limit_constraint(self): + with self.assertRaises(ValidationError): + self.account_age_report_config.line_ids.inferior_limit = 0 + + with self.assertRaises(ValidationError): + self.account_age_report_config.line_ids.inferior_limit = -1 diff --git a/account_financial_report/tests/test_aged_partner_balance.py b/account_financial_report/tests/test_aged_partner_balance.py index 69b86806..9f3d0906 100644 --- a/account_financial_report/tests/test_aged_partner_balance.py +++ b/account_financial_report/tests/test_aged_partner_balance.py @@ -1,10 +1,11 @@ # Copyright 2021 Simone Rubino - Agile Business Group # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo.tests import TransactionCase +from odoo.tests import TransactionCase, tagged from odoo.tools import DEFAULT_SERVER_DATE_FORMAT, test_reports +@tagged("post_install", "-at_install") class TestAgedPartnerBalance(TransactionCase): @classmethod def setUpClass(cls): @@ -20,15 +21,40 @@ class TestAgedPartnerBalance(TransactionCase): ) ) cls.wizard_model = cls.env["aged.partner.balance.report.wizard"] - - def test_report(self): - """Check that report is produced correctly.""" - wizard = self.wizard_model.create( + # Check that report is produced correctly + cls.wizard_with_line_details = cls.wizard_model.create( { "show_move_line_details": True, "receivable_accounts_only": True, } ) + cls.wizard_without_line_details = cls.wizard_model.create( + { + "show_move_line_details": False, + "receivable_accounts_only": True, + } + ) + cls.account_age_report_config = cls.env[ + "account.age.report.configuration" + ].create( + { + "name": "Intervals configuration", + "line_ids": [ + ( + 0, + 0, + { + "name": "1-30", + "inferior_limit": 30, + }, + ), + ], + } + ) + + def test_report_without_aged_report_configuration(self): + """Check that report is produced correctly.""" + wizard = self.wizard_with_line_details wizard.onchange_type_accounts_only() data = wizard._prepare_report_aged_partner_balance() @@ -43,3 +69,56 @@ class TestAgedPartnerBalance(TransactionCase): data=data, ) self.assertTrue(result) + second_wizard = self.wizard_without_line_details + second_wizard.onchange_type_accounts_only() + data = second_wizard._prepare_report_aged_partner_balance() + + # Simulate web client behavior: + # default value is a datetime.date but web client sends back strings + data.update({"date_at": data["date_at"].strftime(DEFAULT_SERVER_DATE_FORMAT)}) + result = test_reports.try_report( + self.env.cr, + self.env.uid, + "account_financial_report.aged_partner_balance", + second_wizard.ids, + data=data, + ) + self.assertTrue(result) + + def test_report_with_aged_report_configuration(self): + """Check that report is produced correctly.""" + wizard = self.wizard_with_line_details + wizard.age_partner_config_id = self.account_age_report_config.id + + wizard.onchange_type_accounts_only() + data = wizard._prepare_report_aged_partner_balance() + + # Simulate web client behavior: + # default value is a datetime.date but web client sends back strings + data.update({"date_at": data["date_at"].strftime(DEFAULT_SERVER_DATE_FORMAT)}) + result = test_reports.try_report( + self.env.cr, + self.env.uid, + "account_financial_report.aged_partner_balance", + wizard.ids, + data=data, + ) + self.assertTrue(result) + + second_wizard = self.wizard_without_line_details + second_wizard.age_partner_config_id = self.account_age_report_config.id + + second_wizard.onchange_type_accounts_only() + data = second_wizard._prepare_report_aged_partner_balance() + + # Simulate web client behavior: + # default value is a datetime.date but web client sends back strings + data.update({"date_at": data["date_at"].strftime(DEFAULT_SERVER_DATE_FORMAT)}) + result = test_reports.try_report( + self.env.cr, + self.env.uid, + "account_financial_report.aged_partner_balance", + second_wizard.ids, + data=data, + ) + self.assertTrue(result) diff --git a/account_financial_report/view/account_age_report_configuration_views.xml b/account_financial_report/view/account_age_report_configuration_views.xml new file mode 100644 index 00000000..aeeff2ec --- /dev/null +++ b/account_financial_report/view/account_age_report_configuration_views.xml @@ -0,0 +1,41 @@ + + + + + Age partner report configuration form + account.age.report.configuration + +
+ + + + + + + + + + + + +
+
+
+ + Age partner report configuration tree + account.age.report.configuration + + + + + + + + + Age Partner Report Configuration + account.age.report.configuration + tree,form + +
diff --git a/account_financial_report/view/res_config_settings_views.xml b/account_financial_report/view/res_config_settings_views.xml new file mode 100644 index 00000000..f8637845 --- /dev/null +++ b/account_financial_report/view/res_config_settings_views.xml @@ -0,0 +1,51 @@ + + + + + res.config.settings + + + + +
+
+
+ Intervals configuration +
+ Here you can set the intervals that will appear on the Aged Partner Balance. +
+
+
+
+
+
+
+
+
+ + + + + diff --git a/account_financial_report/wizard/aged_partner_balance_wizard.py b/account_financial_report/wizard/aged_partner_balance_wizard.py index a9be96da..5f41a143 100644 --- a/account_financial_report/wizard/aged_partner_balance_wizard.py +++ b/account_financial_report/wizard/aged_partner_balance_wizard.py @@ -40,6 +40,9 @@ class AgedPartnerBalanceWizard(models.TransientModel): comodel_name="account.account", help="Ending account in a range", ) + age_partner_config_id = fields.Many2one( + "account.age.report.configuration", string="Intervals configuration" + ) @api.onchange("account_code_from", "account_code_to") def on_change_account_range(self): @@ -140,6 +143,7 @@ class AgedPartnerBalanceWizard(models.TransientModel): "partner_ids": self.partner_ids.ids, "show_move_line_details": self.show_move_line_details, "account_financial_report_lang": self.env.lang, + "age_partner_config_id": self.age_partner_config_id.id, } def _export(self, report_type): diff --git a/account_financial_report/wizard/aged_partner_balance_wizard_view.xml b/account_financial_report/wizard/aged_partner_balance_wizard_view.xml index 634d2631..c02d1d7a 100644 --- a/account_financial_report/wizard/aged_partner_balance_wizard_view.xml +++ b/account_financial_report/wizard/aged_partner_balance_wizard_view.xml @@ -33,6 +33,8 @@ /> +