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
3 changes: 2 additions & 1 deletion addons/hr/models/hr_employee.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ 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)
Expand Down Expand Up @@ -258,6 +257,8 @@ def _lang_get(self):
related='version_id.country_id.code',
groups="hr.group_hr_user"
)
permit_no = fields.Char('Work Permit No', readonly=False, related="version_id.permit_no", inherited=True, 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
1 change: 1 addition & 0 deletions addons/hr/models/hr_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def _get_hr_responsible_domain(self):
spouse_complete_name = fields.Char(string="Spouse Legal Name", groups="hr.group_hr_user", tracking=1)
spouse_birthdate = fields.Date(string="Spouse Birthdate", groups="hr.group_hr_user", tracking=1)
children = fields.Integer(string='Dependent Children', groups="hr.group_hr_user", tracking=1)
permit_no = fields.Char('Work Permit No', groups="hr.group_hr_user", tracking=1)

# Work Information
department_id = fields.Many2one('hr.department', check_company=True, tracking=1, index=True)
Expand Down
4 changes: 2 additions & 2 deletions addons/hr/views/hr_employee_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,8 @@
<field name="contract_date_start" string="Start Date" placeholder="Not Employed" class="o_hr_narrow_field me-3"/>
<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"/>
class="o_hr_narrow_field ms-3" invisible="not contract_date_start" required="fixed_term"/>
<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
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}

.o_accrual {
.o_field_accrual, .o_field_selection, .o_field_filterable_selection {
.o_field_accrual, .o_field_selection, .o_field_day_selection, .o_field_filterable_selection {
width: fit-content !important;

&:not(.o_readonly_modifier) > *:first-child {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { registry } from "@web/core/registry";
import { SelectionField, selectionField } from "@web/views/fields/selection/selection_field";

export class DaySelection extends SelectionField {
static props = {
...SelectionField.props,
month: { type: String, optional: true },
};

get options() {
const options = super.options;
const selectedMonth = this.props.record.data[this.props.month];
if (!selectedMonth) return options;

const maxDays = new Date(2024, parseInt(selectedMonth), 0).getDate();
return options.filter(option => parseInt(option[0]) <= maxDays);
}
}

export const daySelection = {
...selectionField,
component: DaySelection,
extractProps({ attrs }) {
const props = selectionField.extractProps(...arguments);
props.month = attrs.month;
return props;
},
fieldDependencies: ({ attrs }) => [
{ name: attrs.month, type: "selection" },
],
};


registry.category("fields").add("day_selection", daySelection);
1 change: 1 addition & 0 deletions addons/hr_holidays/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@
from . import test_timeoff_overview_my_department_tour
from . import test_hr_leave_report
from . import test_member_of_department
from . import test_time_off_type
34 changes: 34 additions & 0 deletions addons/hr_holidays/tests/test_time_off_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from odoo.addons.hr_holidays.tests.common import TestHrHolidaysCommon


class TestTimeOffType(TestHrHolidaysCommon):

@classmethod
def setUpClass(cls):

super().setUpClass()

cls.work_entry_type_paid = cls.env['hr.work.entry.type'].create({
'name': 'Paid Time Off',
'code': 'Paid Time Off',
'requires_allocation': True,
'request_unit': 'day',
'unit_of_measure': 'day',
'allows_negative': False,
})

cls.allocation = cls.env['hr.leave.allocation'].create({
'name': 'Regular allocation',
'date_from': '2024-01-04',
'work_entry_type_id': cls.work_entry_type_paid.id,
'employee_id': cls.employee_emp.id,
'number_of_days': 10,
})
cls.allocation.action_approve()

def test_time_off_type_selection_with_existing_allocations(self):
self.env['hr.work.entry.type'].with_context(
default_employee_id=self.employee_emp.id,
).search([
('virtual_remaining_leaves', '>', 0),
])
10 changes: 5 additions & 5 deletions addons/hr_holidays/views/hr_leave_accrual_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@
</span>
<span name="biyearly" invisible="frequency != 'biyearly'">
on the
<field nolabel="1" name="first_month_day" class="o_hr_narrow_field-3" placeholder="select a day" required="frequency == 'biyearly'"/>
<field nolabel="1" name="first_month_day" widget="day_selection" month="first_month" class="o_hr_narrow_field-3" placeholder="select a day" required="frequency == 'biyearly'"/>
of
<field name="first_month" class="o_hr_narrow_field-5" placeholder="select a month" required="frequency == 'biyearly'"/>
and the
<field nolabel="1" name="second_month_day" class="o_hr_narrow_field-3" placeholder="select a day" required="frequency == 'biyearly'"/>
<field nolabel="1" name="second_month_day" widget="day_selection" month="second_month" class="o_hr_narrow_field-3" placeholder="select a day" required="frequency == 'biyearly'"/>
of
<field nolabel="1" name="second_month" class="o_hr_narrow_field-5" placeholder="select a month" required="frequency == 'biyearly'"/>
</span>
<span name="yearly" invisible="frequency != 'yearly'">
on the
<field nolabel="1" name="yearly_day" class="o_hr_narrow_field-3" required="frequency == 'yearly'" placeholder="select a day"/>
<field nolabel="1" name="yearly_day" widget="day_selection" month="yearly_month" class="o_hr_narrow_field-3" required="frequency == 'yearly'" placeholder="select a day"/>
of
<field nolabel="1" name="yearly_month" class="o_hr_narrow_field-5" required="frequency == 'yearly'" placeholder="select a month"/>
</span>
Expand Down Expand Up @@ -204,8 +204,8 @@
options="{'links': {'other': 'carryover_custom_date'}, 'observe': 'carryover'}"/>
<span id="carryover_custom_date">
: the
<field name="carryover_day" placeholder="select a day"
required="carryover_date == 'other'"/>
<field name="carryover_day" placeholder="select a day" widget="day_selection" month="carryover_month"
required="carryover_date == 'other'" class="w-100"/>
of
<field name="carryover_month" placeholder="select a month"
required="carryover_date == 'other'"/>
Expand Down