diff options
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/hr_holidays/models/hr_leave_allocation.py | 7 | ||||
| -rw-r--r-- | addons/hr_holidays/views/hr_leave_allocation_views.xml | 11 |
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')]}"/> |
