[FIX] hr_holidays: change label override limit and default visibility

The label and the help message for override limit were confusing, it is
now changed for a less confusing label and help message.

Another confusing thing is that when having a leave type able to
override the limit it should not be visible in the allocations hence it
should not be possible to set the visibility option.
This commit is contained in:
RomainLibert
2018-04-19 10:44:53 +02:00
parent c309ccd7b3
commit 548f92d207
2 changed files with 11 additions and 7 deletions
+9 -5
View File
@@ -40,10 +40,9 @@ class HolidaysType(models.Model):
('wheat', 'Wheat'),
('ivory', 'Ivory')], string='Color in Report', required=True, default='red',
help='This color will be used in the leaves summary located in Reporting > Leaves by Department.')
limit = fields.Boolean('Allow to Override Limit',
help='If you select this check box, the system allows the employees to take more leaves '
'than the available ones for this type and will not take them into account for the '
'"Remaining Legal Leaves" defined on the employee form.')
limit = fields.Boolean('Unlimited',
help="If you select this check box, the system will allow the employees to ask"
"for leaves without allocating some beforehand")
active = fields.Boolean('Active', default=True,
help="If the active field is set to false, it will allow you to hide the leave type without removing it.")
@@ -67,7 +66,7 @@ class HolidaysType(models.Model):
employee_applicability = fields.Selection([('both', 'On Leave As Well As On Allocation'),
('leave', 'Only On Leave'),
('allocation', 'Only On Allocation')],
default='both', string='Available For Employee :',
default=lambda self: 'leave' if self.limit else 'both', string='Available For Employee :',
help='This leave type will be available on Leave / Allocation request based on selected value')
validity_start = fields.Date("Start Date", default=fields.Date.today(),
@@ -88,6 +87,11 @@ class HolidaysType(models.Model):
htype.validity_start > htype.validity_stop:
raise ValidationError(_("End of validity period should be greater than start of validity period"))
@api.onchange('limit')
def _onchange_limit(self):
if self.limit:
self.employee_applicability = 'leave'
@api.multi
@api.depends('validity_start', 'validity_stop', 'limit')
def _compute_valid(self):
@@ -32,13 +32,13 @@
<group name="leave_request" string="Leave Request">
<field name="time_type" groups="base.group_no_one"/>
<field name="limit"/>
<field name="sequence" attrs="{'invisible': [('limit', '=', 'False')]}" groups="base.group_no_one"/>
<field name="sequence" attrs="{'invisible': [('limit', '=', False)]}" groups="base.group_no_one"/>
</group>
<group name="validation" string="Validation">
<field name="validation_type" widget="radio"/>
</group>
<group name="visibility" string="Visibility">
<field name="employee_applicability" widget="radio"/>
<field name="employee_applicability" widget="radio" attrs="{'readonly': [('limit', '=', True)]}"/>
</group>
<group name="calendar" string="Calendar">
<field name="categ_id"/>