diff --git a/contract/models/contract_recurrency_mixin.py b/contract/models/contract_recurrency_mixin.py index cbbcd5a11..f84f27335 100644 --- a/contract/models/contract_recurrency_mixin.py +++ b/contract/models/contract_recurrency_mixin.py @@ -91,6 +91,7 @@ class ContractRecurrencyMixin(models.AbstractModel): @api.depends("next_period_date_start") def _compute_recurring_next_date(self): + self.recurring_next_date = False for rec in self.filtered("next_period_date_start"): rec.recurring_next_date = self.get_next_invoice_date( rec.next_period_date_start, diff --git a/contract/tests/test_contract.py b/contract/tests/test_contract.py index f0b01a362..6fbff2c11 100644 --- a/contract/tests/test_contract.py +++ b/contract/tests/test_contract.py @@ -2384,3 +2384,11 @@ class TestContract(TestContractBase): action = self.contract.action_preview() self.assertIn("/my/contracts/", action["url"]) self.assertIn("access_token=", action["url"]) + + def test_contract_line_termination(self): + """Don't fail when the line receives an end date.""" + self.contract.recurring_create_invoice() + self.acct_line.date_end = "2018-02-14" + self.assertFalse(self.acct_line.recurring_next_date) + # This doesn't give any error + self.contract.recurring_create_invoice()