Files
enterprise-addons/base_automation_hr/models/base_automation.py
T

20 lines
811 B
Python

# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models
class BaseAutomation(models.Model):
""" Add resource and calendar for time-based conditions """
_inherit = 'base.automation'
trg_date_resource_field_id = fields.Many2one('ir.model.fields', string='Use employee work schedule', help='Use the user\'s working schedule.')
@api.model
def _get_calendar(self, automation, record):
if automation.trg_date_range_type == 'day' and automation.trg_date_resource_field_id:
user = record[automation.trg_date_resource_field_id.name]
calendar = user.employee_id.version_id.resource_calendar_id
if calendar:
return calendar
return super()._get_calendar(automation, record)