__init__.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. # -*- coding: utf-8 -*-
  2. # Part of Odoo. See LICENSE file for full copyright and licensing details.
  3. from . import controllers
  4. from . import models
  5. from . import report
  6. from . import wizard
  7. from . import populate
  8. from odoo import api, SUPERUSER_ID
  9. from odoo.tools.sql import create_index
  10. def _check_exists_collaborators_for_project_sharing(env):
  11. """ Check if it exists at least a collaborator in a shared project
  12. If it is the case we need to active the portal rules added only for this feature.
  13. """
  14. collaborator = env['project.collaborator'].search([], limit=1)
  15. if collaborator:
  16. # Then we need to enable the access rights linked to project sharing for the portal user
  17. env['project.collaborator']._toggle_project_sharing_portal_rules(True)
  18. def _project_post_init(cr, registry):
  19. env = api.Environment(cr, SUPERUSER_ID, {})
  20. _check_exists_collaborators_for_project_sharing(env)
  21. # Index to improve the performance of burndown chart.
  22. project_task_stage_field_id = env['ir.model.fields']._get_ids('project.task').get('stage_id')
  23. create_index(
  24. cr,
  25. 'mail_tracking_value_mail_message_id_old_value_integer_task_stage',
  26. env['mail.tracking.value']._table,
  27. ['mail_message_id', 'old_value_integer'],
  28. where=f'field={project_task_stage_field_id}'
  29. )