From bfa5d366b212086285f03720f7dde58bbc01c8cb Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Tue, 2 Apr 2019 16:14:52 +0200 Subject: [PATCH] [IMP] - Add forecast trigger for contract update --- contract_forecast/models/contract.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/contract_forecast/models/contract.py b/contract_forecast/models/contract.py index 9a1f6344..4a973383 100644 --- a/contract_forecast/models/contract.py +++ b/contract_forecast/models/contract.py @@ -22,3 +22,21 @@ class AccountAnalyticAccount(models.Model): "view_mode": "pivot,tree", "context": context, } + + @api.model + def _get_forecast_update_trigger_fields(self): + return [] + + @api.multi + def write(self, values): + res = super(AccountAnalyticAccount, self).write(values) + if any( + [ + field in values + for field in self._get_forecast_update_trigger_fields() + ] + ): + for rec in self: + for contract_line in rec.recurring_invoice_line_ids: + contract_line.with_delay()._generate_forecast_periods() + return res