[IMP] - improve post_init_hook and _generate_forecast_periods

This commit is contained in:
sbejaoui
2019-03-14 10:33:27 +01:00
parent ea2e793c59
commit 71a88097b9
2 changed files with 11 additions and 12 deletions

View File

@@ -66,6 +66,7 @@ class AccountAnalyticInvoiceLine(models.Model):
def _generate_forecast_periods(self):
values = []
for rec in self:
rec.forecast_period_ids.unlink()
if rec.recurring_next_date:
last_date_invoiced = (
rec.last_date_invoiced
@@ -99,11 +100,6 @@ class AccountAnalyticInvoiceLine(models.Model):
)
return self.env["contract.line.forecast.period"].create(values)
@api.multi
@job(default_channel=QUEUE_CHANNEL)
def _unlink_forecast_periods(self):
return self.mapped("forecast_period_ids").unlink()
@api.model
def create(self, values):
contract_lines = super(AccountAnalyticInvoiceLine, self).create(values)
@@ -140,6 +136,5 @@ class AccountAnalyticInvoiceLine(models.Model):
]
):
for rec in self:
rec._unlink_forecast_periods()
rec._generate_forecast_periods()
rec.with_delay()._generate_forecast_periods()
return res