mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[FIX] - forecast should continue after contract line date_end if ot is set to auto_renew
This commit is contained in:
@@ -54,11 +54,11 @@ class AccountAnalyticInvoiceLine(models.Model):
|
|||||||
if self.is_canceled or not self.active:
|
if self.is_canceled or not self.active:
|
||||||
return False
|
return False
|
||||||
contract_forecast_end_date = self._get_contract_forecast_end_date()
|
contract_forecast_end_date = self._get_contract_forecast_end_date()
|
||||||
if not self.date_end:
|
if not self.date_end or self.is_auto_renew:
|
||||||
return period_date_end <= contract_forecast_end_date
|
return period_date_end < contract_forecast_end_date
|
||||||
return (
|
return (
|
||||||
period_date_end < self.date_end
|
period_date_end < self.date_end
|
||||||
and period_date_end <= contract_forecast_end_date
|
and period_date_end < contract_forecast_end_date
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
@@ -71,7 +71,7 @@ class AccountAnalyticInvoiceLine(models.Model):
|
|||||||
last_date_invoiced = (
|
last_date_invoiced = (
|
||||||
rec.last_date_invoiced
|
rec.last_date_invoiced
|
||||||
if rec.last_date_invoiced
|
if rec.last_date_invoiced
|
||||||
else rec.date_start
|
else rec.date_start - relativedelta(days=1)
|
||||||
)
|
)
|
||||||
period_date_end = last_date_invoiced
|
period_date_end = last_date_invoiced
|
||||||
recurring_next_date = rec.recurring_next_date
|
recurring_next_date = rec.recurring_next_date
|
||||||
@@ -79,7 +79,9 @@ class AccountAnalyticInvoiceLine(models.Model):
|
|||||||
period_date_end
|
period_date_end
|
||||||
):
|
):
|
||||||
period_dates = rec._get_period_to_invoice(
|
period_dates = rec._get_period_to_invoice(
|
||||||
last_date_invoiced, recurring_next_date
|
last_date_invoiced,
|
||||||
|
recurring_next_date,
|
||||||
|
stop_at_date_end=not rec.is_auto_renew,
|
||||||
)
|
)
|
||||||
period_date_start, period_date_end, recurring_next_date = (
|
period_date_start, period_date_end, recurring_next_date = (
|
||||||
period_dates
|
period_dates
|
||||||
@@ -124,6 +126,7 @@ class AccountAnalyticInvoiceLine(models.Model):
|
|||||||
"recurring_interval",
|
"recurring_interval",
|
||||||
"is_canceled",
|
"is_canceled",
|
||||||
"active",
|
"active",
|
||||||
|
"is_auto_renew",
|
||||||
]
|
]
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
|
|||||||
@@ -115,3 +115,31 @@ class TestContractLineForecastPeriod(TestContractBase):
|
|||||||
)
|
)
|
||||||
self.assertTrue(self.acct_line.forecast_period_ids)
|
self.assertTrue(self.acct_line.forecast_period_ids)
|
||||||
self.assertEqual(len(self.acct_line.forecast_period_ids), 1)
|
self.assertEqual(len(self.acct_line.forecast_period_ids), 1)
|
||||||
|
|
||||||
|
@mute_logger("odoo.addons.queue_job.models.base")
|
||||||
|
def test_forecast_period_on_contract_line_update_7(self):
|
||||||
|
self.acct_line.write(
|
||||||
|
{
|
||||||
|
'date_end': "2019-6-05",
|
||||||
|
'recurring_rule_type': "monthlylastday",
|
||||||
|
'recurring_invoicing_type': 'pre-paid',
|
||||||
|
'is_auto_renew': True,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
self.acct_line._onchange_date_start()
|
||||||
|
self.assertTrue(self.acct_line.forecast_period_ids)
|
||||||
|
self.assertEqual(len(self.acct_line.forecast_period_ids), 13)
|
||||||
|
|
||||||
|
@mute_logger("odoo.addons.queue_job.models.base")
|
||||||
|
def test_forecast_period_on_contract_line_update_8(self):
|
||||||
|
self.acct_line.write(
|
||||||
|
{
|
||||||
|
'date_start': "2019-01-14",
|
||||||
|
'recurring_next_date': "2019-01-31",
|
||||||
|
'date_end': "2019-01-14",
|
||||||
|
'recurring_rule_type': "monthlylastday",
|
||||||
|
'recurring_invoicing_type': 'post-paid',
|
||||||
|
}
|
||||||
|
)
|
||||||
|
self.assertTrue(self.acct_line.forecast_period_ids)
|
||||||
|
self.assertEqual(len(self.acct_line.forecast_period_ids), 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user