From 3e529d0037e527372803aaef53535a94a546417e Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Tue, 7 Jan 2020 12:06:14 +0100 Subject: [PATCH] [IMP] - Add failing test for forecast generation of auto renewal contract lines If a contract line is set to auto renew the forecast should continue after the date end and stop at the company forecast period --- .../test_contract_line_forecast_period.py | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/contract_forecast/tests/test_contract_line_forecast_period.py b/contract_forecast/tests/test_contract_line_forecast_period.py index 2414c91b7..b52efbcc8 100644 --- a/contract_forecast/tests/test_contract_line_forecast_period.py +++ b/contract_forecast/tests/test_contract_line_forecast_period.py @@ -260,3 +260,27 @@ class TestContractLineForecastPeriod(TestContractBase): Date.to_date("2020-01-01"), ), ) + + @mute_logger("odoo.addons.queue_job.models.base") + def test_forecast_period_for_auto_renew_contract(self): + """If a contract line is set to auto renew the forecast should continue + after the date end and stop at the company forecast period""" + # Set the company forecast period to three years + self.acct_line.contract_id.company_id.contract_forecast_interval = 36 + self.acct_line.write( + { + 'date_start': Date.today(), + 'recurring_next_date': Date.today(), + 'date_end': Date.today() + relativedelta(years=1), + 'recurring_rule_type': "monthlylastday", + 'last_date_invoiced': False, + 'recurring_invoicing_type': 'pre-paid', + 'is_auto_renew': False, + } + ) + self.assertTrue(self.acct_line.forecast_period_ids) + self.assertEqual(len(self.acct_line.forecast_period_ids), 13) + + self.acct_line.write({'is_auto_renew': True}) + self.assertTrue(self.acct_line.forecast_period_ids) + self.assertEqual(len(self.acct_line.forecast_period_ids), 37)