From 01acbaa35578b44f1a632737fae84e0637ca2e8e Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Tue, 7 Jan 2020 12:18:07 +0100 Subject: [PATCH] [IMP] - add a non-regression test: forecast for undefined date end contracts If a contract line have and undefined date end the forecast should continue to the company forecast period --- .../test_contract_line_forecast_period.py | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/contract_forecast/tests/test_contract_line_forecast_period.py b/contract_forecast/tests/test_contract_line_forecast_period.py index b52efbcc8..18d1c6dd1 100644 --- a/contract_forecast/tests/test_contract_line_forecast_period.py +++ b/contract_forecast/tests/test_contract_line_forecast_period.py @@ -284,3 +284,26 @@ class TestContractLineForecastPeriod(TestContractBase): 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) + + @mute_logger("odoo.addons.queue_job.models.base") + def test_forecast_period_for_undefined_date_end_contract(self): + """If a contract line have and undefined date end the forecast should + continue to the company forecast period""" + 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({'date_end': False}) + self.assertTrue(self.acct_line.forecast_period_ids) + self.assertEqual(len(self.acct_line.forecast_period_ids), 37)