[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>
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -159,12 +159,13 @@
|
||||
<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"
|
||||
|
||||
Reference in New Issue
Block a user