res_config_settings.py 1.4 KB

123456789101112131415161718192021222324252627282930
  1. # -*- coding: utf-8 -*-
  2. # Part of Odoo. See LICENSE file for full copyright and licensing details.
  3. from odoo import api, fields, models
  4. class ResConfigSettings(models.TransientModel):
  5. _inherit = 'res.config.settings'
  6. internal_project_id = fields.Many2one(
  7. related='company_id.internal_project_id', required=True, string="Internal Project",
  8. domain="[('company_id', '=', company_id)]", readonly=False,
  9. help="The default project used when automatically generating timesheets via time off requests."
  10. " You can specify another project on each time off type individually.")
  11. leave_timesheet_task_id = fields.Many2one(
  12. related='company_id.leave_timesheet_task_id', string="Time Off Task", readonly=False,
  13. domain="[('company_id', '=', company_id), ('project_id', '=?', internal_project_id)]",
  14. help="The default task used when automatically generating timesheets via time off requests."
  15. " You can specify another task on each time off type individually.")
  16. @api.onchange('internal_project_id')
  17. def _onchange_timesheet_project_id(self):
  18. if self.internal_project_id != self.leave_timesheet_task_id.project_id:
  19. self.leave_timesheet_task_id = False
  20. @api.onchange('leave_timesheet_task_id')
  21. def _onchange_timesheet_task_id(self):
  22. if self.leave_timesheet_task_id:
  23. self.internal_project_id = self.leave_timesheet_task_id.project_id