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
2 changes: 1 addition & 1 deletion addons/hr/models/hr_employee.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def _lang_get(self):
}
"""

permit_no = fields.Char('Work Permit No', groups="hr.group_hr_user", tracking=True)
permit_no = fields.Char(readonly=False, related='version_id.permit_no', inherited=True, groups="hr.group_hr_user")
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
1 change: 1 addition & 0 deletions addons/hr/models/hr_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ def _get_hr_responsible_domain(self):
is_flexible = fields.Boolean(compute='_compute_is_flexible', store=True, groups="hr.group_hr_user")
is_fully_flexible = fields.Boolean(compute='_compute_is_flexible', store=True, groups="hr.group_hr_user")
tz = fields.Selection(_tz_get, string='Timezone', required=True, default=lambda self: self.env.context.get('tz') or self.env.user.tz or 'UTC')
permit_no = fields.Char(string='Work Permit No', tracking=True, groups="hr.group_hr_user")

# Contract Information
contract_date_start = fields.Date('Contract Start Date', tracking=1, groups="hr.group_hr_manager")
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 All @@ -20,7 +20,7 @@
field-sizing: content;
}

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

export class DaySelectionField extends SelectionField {
static props = {
...SelectionField.props,
month_field: {
type: String,
optional: true
},
}

get options() {
let month = parseInt(this.props.record.data[this.props.month_field]);
if (month) {
let days_number = new Date(2024, month, 0).getDate()
let new_options = []
for (let i = 0 ; i < days_number ; i++) new_options[i] = [i + 1, i + 1]
return new_options
}
else {
return super.options
}
}
}

export const daySelection = {
...selectionField,
component: DaySelectionField,
extractProps({ options }) {
const props = selectionField.extractProps(...arguments);
props.month_field = options["month_field"];
return props;
},
fieldDependencies({ options }){
if (options["month_field"]) {
return [{
"name": options["month_field"]
}]
}
},
};

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_work_entry_type_search
40 changes: 40 additions & 0 deletions addons/hr_holidays/tests/test_work_entry_type_search.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from odoo.tests import tagged

from odoo.addons.hr_holidays.tests.common import TestHrHolidaysCommon


@tagged("work_entry_search")
class TestWorkEntryTypeSearch(TestHrHolidaysCommon):
def test_work_entry_type_search(self):
employee_test = self.env["hr.employee"].create({"name": "Test Employee"})

work_entry_type_test = self.env["hr.work.entry.type"].create(
{
"name": "Paid Time Off",
"code": "Paid Time Off",
"requires_allocation": True,
"allocation_validation_type": "no_validation",
"request_unit": "day",
"unit_of_measure": "day",
}
)

self.env["hr.leave.allocation"].create(
{
"employee_id": employee_test.id,
"work_entry_type_id": work_entry_type_test.id,
"number_of_days": 1,
}
)

work_entry_type_search_test = (
self.env["hr.work.entry.type"]
.with_context(employee_id=employee_test.id)
.search([("virtual_remaining_leaves", ">", 0)])
)

self.assertIn(
work_entry_type_test,
work_entry_type_search_test,
"Should have found the work entry type that was created.",
)
8 changes: 4 additions & 4 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" options="{'month_field' : '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" options="{'month_field' : '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" options="{'month_field' : '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,7 +204,7 @@
options="{'links': {'other': 'carryover_custom_date'}, 'observe': 'carryover'}"/>
<span id="carryover_custom_date">
: the
<field name="carryover_day" placeholder="select a day"
<field name="carryover_day" widget="day_selection" options="{'month_field': 'carryover_month'}" placeholder="select a day"
required="carryover_date == 'other'"/>
of
<field name="carryover_month" placeholder="select a month"
Expand Down