diff options
| author | Goffin Simon <sig@odoo.com> | 2019-11-21 13:07:27 +0000 |
|---|---|---|
| committer | Goffin Simon <sig@odoo.com> | 2019-11-25 12:18:17 +0000 |
| commit | 5a72faf721505ca61faecf8bbe79e1260e62a95b (patch) | |
| tree | 613ed8dd20794f062adb46b0b75bac9d5592de30 | |
| parent | a0e8135449c0b0625b652f119417c27c78b2712c (diff) | |
[FIX] hr_holidays: Impossible to allocate future leave type
Steps to reproduce the bug:
- Let's consider Today = 21/11/2019 and Employee E
- Create a new hr.leave.type LT and set a validity from 01/01/2020 to 31/12/2020
- Set mode = Free Allocation Request and Validation = No Validation
- Try to create leave allocations for LT
Bug:
It was impossible to create a leave allocation for LT because Today < 01/01/2020
So it was impossible to allocate future leave.
We had to wait the 01/01/2020 to make the allocation of LT leaves
opw:2126300
closes odoo/odoo#40815
X-original-commit: 2b1810daeb13bba8405b663cf401ffab6eba5e24
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
| -rw-r--r-- | addons/hr_holidays/i18n/hr_holidays.pot | 6 | ||||
| -rw-r--r-- | addons/hr_holidays/models/hr_leave_allocation.py | 8 |
2 files changed, 9 insertions, 5 deletions
diff --git a/addons/hr_holidays/i18n/hr_holidays.pot b/addons/hr_holidays/i18n/hr_holidays.pot index 0b639d451af..b9300baa73b 100644 --- a/addons/hr_holidays/i18n/hr_holidays.pot +++ b/addons/hr_holidays/i18n/hr_holidays.pot @@ -2870,6 +2870,12 @@ msgstr "" #. module: hr_holidays #: code:addons/hr_holidays/models/hr_leave_allocation.py:0 #, python-format +msgid "You can allocate %s only before %s" +msgstr "" + +#. module: hr_holidays +#: code:addons/hr_holidays/models/hr_leave_allocation.py:0 +#, python-format msgid "You can allocate %s only between %s and %s" msgstr "" diff --git a/addons/hr_holidays/models/hr_leave_allocation.py b/addons/hr_holidays/models/hr_leave_allocation.py index d1c365fd36a..b9faa215553 100644 --- a/addons/hr_holidays/models/hr_leave_allocation.py +++ b/addons/hr_holidays/models/hr_leave_allocation.py @@ -386,14 +386,12 @@ class HolidaysAllocation(models.Model): @api.constrains('holiday_status_id') def _check_leave_type_validity(self): for allocation in self: - if allocation.holiday_status_id.validity_start and allocation.holiday_status_id.validity_stop: - vstart = allocation.holiday_status_id.validity_start + if allocation.holiday_status_id.validity_stop: vstop = allocation.holiday_status_id.validity_stop today = fields.Date.today() - if vstart > today or vstop < today: - raise ValidationError(_('You can allocate %s only between %s and %s') % (allocation.holiday_status_id.display_name, - allocation.holiday_status_id.validity_start, allocation.holiday_status_id.validity_stop)) + if vstop < today: + raise ValidationError(_('You can allocate %s only before %s') % (allocation.holiday_status_id.display_name, allocation.holiday_status_id.validity_stop)) @api.model def create(self, values): |
