diff options
| author | RomainLibert <rli@odoo.com> | 2018-04-18 15:55:54 +0200 |
|---|---|---|
| committer | RomainLibert <rli@odoo.com> | 2018-04-19 10:44:53 +0200 |
| commit | 548f92d2073ec94b0836a64c8d0ead524fd7a700 (patch) | |
| tree | 55698cabc389f7ff835d542666f71edc4742832c | |
| parent | c309ccd7b3d7e2f4884f6e9e47a98d64ceac8ea1 (diff) | |
[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.
| -rw-r--r-- | addons/hr_holidays/models/hr_leave_type.py | 14 | ||||
| -rw-r--r-- | addons/hr_holidays/views/hr_leave_type_views.xml | 4 |
2 files changed, 11 insertions, 7 deletions
diff --git a/addons/hr_holidays/models/hr_leave_type.py b/addons/hr_holidays/models/hr_leave_type.py index b70edf35fe6..bf94fbfac27 100644 --- a/addons/hr_holidays/models/hr_leave_type.py +++ b/addons/hr_holidays/models/hr_leave_type.py @@ -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): diff --git a/addons/hr_holidays/views/hr_leave_type_views.xml b/addons/hr_holidays/views/hr_leave_type_views.xml index d9b556106d6..2a0cf8600a6 100644 --- a/addons/hr_holidays/views/hr_leave_type_views.xml +++ b/addons/hr_holidays/views/hr_leave_type_views.xml @@ -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"/> |
