[17.0][IMP] account_financial_report: Set custom intervales in aged report

This commit is contained in:
Carolina Fernandez
2024-04-15 13:37:21 +02:00
committed by chaule97
parent 18a8cef8af
commit 6d6937346a
21 changed files with 1217 additions and 473 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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)