You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.2 KiB

  1. # Copyright 2019 ACSONE SA/NV
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  3. from odoo import _, api, models
  4. class ContractContract(models.Model):
  5. _inherit = "contract.contract"
  6. @api.multi
  7. def action_show_contract_forecast(self):
  8. self.ensure_one()
  9. context = {'search_default_groupby_date_invoice': True}
  10. context.update(self.env.context)
  11. return {
  12. "type": "ir.actions.act_window",
  13. "name": _("Contract Forecast"),
  14. "res_model": "contract.line.forecast.period",
  15. "domain": [("contract_id", "=", self.id)],
  16. "view_mode": "pivot,tree",
  17. "context": context,
  18. }
  19. @api.model
  20. def _get_forecast_update_trigger_fields(self):
  21. return []
  22. @api.multi
  23. def write(self, values):
  24. res = super(ContractContract, self).write(values)
  25. if any(
  26. [
  27. field in values
  28. for field in self._get_forecast_update_trigger_fields()
  29. ]
  30. ):
  31. for rec in self:
  32. for contract_line in rec.contract_line_ids:
  33. contract_line.with_delay()._generate_forecast_periods()
  34. return res