summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authornia-odoo <nia@odoo.com>2020-03-09 09:38:16 +0000
committerBarad Mahendra <mba@openerp.com>2020-03-27 10:12:23 +0000
commit5cc42022fc159e71ccd2dde122ddde80dd66e23e (patch)
tree9e0f799fbfc4873bd1724c6c584865b2b173147e /addons
parentfbd1d7584a0c7c505c1af8a18ae245ac2aac52a6 (diff)
[IMP] hr_holidays: Allow to select start date for accruals for allocation
Currently it was not possible select start date for accruals leave allocation. it was default taken as today's date. So purpose of this task is to make start date field of accrual time off visible so user do not have to wait until day to add a day off In this commit, we make start date field of accrual time off visible with default value as today and also check for the start date in cron method. closes odoo/odoo#46811 Taskid: 2199326 Closes: #46811 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/hr_holidays/models/hr_leave_allocation.py7
-rw-r--r--addons/hr_holidays/views/hr_leave_allocation_views.xml11
2 files changed, 9 insertions, 9 deletions
diff --git a/addons/hr_holidays/models/hr_leave_allocation.py b/addons/hr_holidays/models/hr_leave_allocation.py
index 60aa7985ad8..0f69967cbeb 100644
--- a/addons/hr_holidays/models/hr_leave_allocation.py
+++ b/addons/hr_holidays/models/hr_leave_allocation.py
@@ -56,7 +56,7 @@ class HolidaysAllocation(models.Model):
"\nThe status is 'Refused', when an allocation request is refused by manager." +
"\nThe status is 'Approved', when an allocation request is approved by manager.")
date_from = fields.Datetime(
- 'Start Date', readonly=True, index=True, copy=False,
+ 'Start Date', readonly=True, index=True, copy=False, default=fields.Date.context_today,
states={'draft': [('readonly', False)], 'confirm': [('readonly', False)]}, tracking=True)
date_to = fields.Datetime(
'End Date', readonly=True, copy=False,
@@ -188,7 +188,7 @@ class HolidaysAllocation(models.Model):
# in order to not allocate him/her too much leaves
start_date = holiday.employee_id._get_date_start_work()
# If employee is created after the period, we cancel the computation
- if period_end <= start_date:
+ if period_end <= start_date or period_end < holiday.date_from:
holiday.write(values)
continue
@@ -399,8 +399,6 @@ class HolidaysAllocation(models.Model):
@api.model
def create(self, values):
""" Override to avoid automatic logging of creation """
- if values.get('allocation_type', 'regular') == 'accrual':
- values['date_from'] = fields.Datetime.now()
employee_id = values.get('employee_id', False)
if not values.get('department_id'):
values.update({'department_id': self.env['hr.employee'].browse(employee_id).department_id.id})
@@ -446,6 +444,7 @@ class HolidaysAllocation(models.Model):
'parent_id': self.id,
'employee_id': employee.id,
'allocation_type': self.allocation_type,
+ 'date_from': self.date_from,
'date_to': self.date_to,
'interval_unit': self.interval_unit,
'interval_number': self.interval_number,
diff --git a/addons/hr_holidays/views/hr_leave_allocation_views.xml b/addons/hr_holidays/views/hr_leave_allocation_views.xml
index 68212af9c7f..e2d66fb694b 100644
--- a/addons/hr_holidays/views/hr_leave_allocation_views.xml
+++ b/addons/hr_holidays/views/hr_leave_allocation_views.xml
@@ -159,13 +159,14 @@
<attribute name="invisible">0</attribute>
</xpath>
<xpath expr="//field[@name='allocation_type']" position="after">
- <label for="date_to" string=""
- attrs="{'invisible': [('allocation_type', '=', 'regular')]}"/>
+ <label for="date_from" attrs="{'invisible': [('allocation_type', '=', 'regular')]}"/>
+ <div class="o_row" attrs="{'invisible': [('allocation_type', '=', 'regular')]}">
+ <field name="date_from" widget="date" required="1" class="mr-2"/>
+ Run until <field name="date_to" help="If no value set, runs indefinitely" class="ml-2" widget="date"/>
+ </div>
+ <label for="date_from" invisible="1"/>
<div attrs="{'invisible': [('allocation_type', '=', 'regular')]}">
<div class="o_row">
- Run until <field name="date_to" string="Run Until" help="If no value set, runs indefinitely" class="ml-2" widget="date"/>
- </div>
- <div class="o_row">
<span>Add</span>
<field name="number_per_interval" class="ml8"
attrs="{'required': [('allocation_type', '=', 'accrual')]}"/>