Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions addons/hr/models/hr_employee.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,8 @@ def _lang_get(self):
}
"""

permit_no = fields.Char('Work Permit No', groups="hr.group_hr_user", tracking=True)
visa_no = fields.Char('Visa No', groups="hr.group_hr_user", tracking=True)
visa_expire = fields.Date('Visa Expiration Date', groups="hr.group_hr_user", tracking=True)
work_permit_expiration_date = fields.Date('Work Permit Expiration Date', groups="hr.group_hr_user", tracking=True)
has_work_permit = fields.Binary(string="Work Permit", groups="hr.group_hr_user")
work_permit_scheduled_activity = fields.Boolean(default=False, groups="hr.group_hr_user")
work_permit_name = fields.Char('work_permit_name', compute='_compute_work_permit_name', groups="hr.group_hr_user")
Expand Down Expand Up @@ -258,6 +256,8 @@ def _lang_get(self):
related='version_id.country_id.code',
groups="hr.group_hr_user"
)
permit_no = fields.Char(related='version_id.permit_no', inherited=True, readonly=False, groups="hr.group_hr_user", tracking=True)
work_permit_expiration_date = fields.Date(related='version_id.work_permit_expiration_date', readonly=False, groups="hr.group_hr_user", tracking=True)
# Direct subordinates
parent_id = fields.Many2one('hr.employee', 'Manager', tracking=True, index=True,
domain="['|', ('company_id', '=', False), ('company_id', 'in', allowed_company_ids)]")
Expand Down
2 changes: 2 additions & 0 deletions addons/hr/models/hr_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ def _get_hr_responsible_domain(self):
departure_apply_date = fields.Date(related='departure_id.apply_date', groups="hr.group_hr_user")

resource_calendar_id = fields.Many2one('resource.calendar', inverse='_inverse_resource_calendar_id', check_company=True, string="Working Hours", index='btree_not_null', tracking=1)
permit_no = fields.Char(string='Work Permit No', groups="hr.group_hr_user", tracking=1)
work_permit_expiration_date = fields.Date(string='Work Permit Expiration Date', groups="hr.group_hr_user", tracking=1)
hours_per_week = fields.Float(string="Hours per Week", compute='_compute_hours_per_week', store=True, readonly=False)
hours_per_day = fields.Float(string="Hours per Day", compute='_compute_hours_per_day', store=True, readonly=False)
is_flexible = fields.Boolean(compute='_compute_is_flexible', store=True, groups="hr.group_hr_user")
Expand Down
2 changes: 1 addition & 1 deletion addons/hr/views/hr_employee_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@
<span invisible="not contract_date_start">to</span>
<field name="contract_date_end" string="End Date" placeholder="Indefinite" widget="date_dynamic_min" options="{'min_date_field': 'contract_date_start'}"
class="o_hr_narrow_field ms-3" invisible="not contract_date_start"/>
<widget name="button_new_contract"/>
<widget name="button_new_contract" invisible="not contract_date_start"/>
</div>
<field name="fixed_term" string="Fixed Term" invisible="1"/>
<label for="wage"/>
Expand Down
2 changes: 1 addition & 1 deletion addons/hr_holidays/models/hr_work_entry_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def _search_max_leaves(self, operator, value):

def _search_virtual_remaining_leaves(self, operator, value):
def is_valid(work_entry_type):
return not work_entry_type.requires_allocation or op(work_entry_type.virtual_remaining_leaves)
return not work_entry_type.requires_allocation or op(work_entry_type.virtual_remaining_leaves, value)
op = PY_OPERATORS.get(operator)
if not op:
return NotImplemented
Expand Down
28 changes: 28 additions & 0 deletions addons/hr_holidays/tests/test_hr_work_entry_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,31 @@ def test_change_count_days_as(self):

with self.assertRaises(ValidationError):
work_entry_type.count_days_as = 'working'

def test_search_virtual_remaining_leaves(self):
"""Test search method on virtual_remaining_leaves"""
employee = self.env['hr.employee'].create({'name': 'Test Employee'})

allocated_work_entry_type = self.env['hr.work.entry.type'].create({
'name': 'Test Time Off',
'code': 'Test Time Off 5',
'requires_allocation': True,
'request_unit': 'day',
})

self.env['hr.leave.allocation'].sudo().create({
'state': 'confirm',
'work_entry_type_id': allocated_work_entry_type.id,
'employee_id': employee.id,
'number_of_days': 10,
}).action_approve()

env_with_context = self.env['hr.work.entry.type'].with_context(employee_id=employee.id)

types_greater_than_5 = env_with_context.search([('virtual_remaining_leaves', '>', 5)])

self.assertIn(
allocated_work_entry_type,
types_greater_than_5,
"Search failed: Should have found the work entry type within search results"
)