diff --git a/allow_negative_leave_and_allocation/models/__init__.py b/allow_negative_leave_and_allocation/models/__init__.py index ed1f735..fd469c5 100644 --- a/allow_negative_leave_and_allocation/models/__init__.py +++ b/allow_negative_leave_and_allocation/models/__init__.py @@ -1 +1 @@ -from . import hr_leave_type, hr_leave \ No newline at end of file +from . import hr_leave_type, hr_leave, hr_leave_allocation \ No newline at end of file diff --git a/allow_negative_leave_and_allocation/models/hr_leave_allocation.py b/allow_negative_leave_and_allocation/models/hr_leave_allocation.py new file mode 100644 index 0000000..09ef58f --- /dev/null +++ b/allow_negative_leave_and_allocation/models/hr_leave_allocation.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +# Copyright (c) 2005-2006 Axelor SARL. (http://www.axelor.com) + +from odoo import models + +class HrLeaveAllocation(models.Model): + _inherit = "hr.leave.allocation" + + _sql_constraints = [ + ('type_value', + "CHECK( (holiday_type='employee' AND (employee_id IS NOT NULL OR multi_employee IS TRUE)) or " + "(holiday_type='category' AND category_id IS NOT NULL) or " + "(holiday_type='department' AND department_id IS NOT NULL) or " + "(holiday_type='company' AND mode_company_id IS NOT NULL))", + "The employee, department, company or employee category of this request is missing. Please make sure that your user login is linked to an employee."), + ('duration_check', "CHECK((allocation_type != 'regular'))", "The duration must be greater than 0."), + ] \ No newline at end of file