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.

30 lines
875 B

  1. # Copyright 2019 ACSONE SA/NV
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  3. import logging
  4. from odoo import api
  5. from odoo.tools import SUPERUSER_ID
  6. _logger = logging.getLogger(__name__)
  7. def post_init_hook(cr, registry):
  8. """
  9. Generate contract line forecast periods
  10. """
  11. _logger.info(
  12. "Post init hook for module post_init_hook: "
  13. "Generate contract line forecast periods"
  14. )
  15. with api.Environment.manage():
  16. env = api.Environment(cr, SUPERUSER_ID, {})
  17. offset = 0
  18. while True:
  19. contract_lines = env["account.analytic.invoice.line"].search(
  20. [('is_canceled', '=', False)], limit=100, offset=offset
  21. )
  22. contract_lines.with_delay()._generate_forecast_periods()
  23. if len(contract_lines) < 100:
  24. break
  25. offset += 100