diff --git a/addons/hr/models/hr_employee.py b/addons/hr/models/hr_employee.py index 4b653444f20ec6..a1db702a32f0e8 100644 --- a/addons/hr/models/hr_employee.py +++ b/addons/hr/models/hr_employee.py @@ -617,8 +617,7 @@ def _compute_legal_name(self): @api.depends('current_version_id') @api.depends_context('version_id') def _compute_version_id(self): - context_version_id = self.env.context.get('version_id', False) - context_version = self.env['hr.version'].browse(context_version_id).exists() if context_version_id else self.env['hr.version'] + context_version = self.env['hr.version'].browse(self.env.context.get('version_id', False)) for employee in self: if context_version.employee_id == self: diff --git a/addons/hr/static/src/components/button_new_contract/button_new_contract.xml b/addons/hr/static/src/components/button_new_contract/button_new_contract.xml index cdcdbcebea5d0b..0c640d5b88d4c4 100644 --- a/addons/hr/static/src/components/button_new_contract/button_new_contract.xml +++ b/addons/hr/static/src/components/button_new_contract/button_new_contract.xml @@ -2,8 +2,8 @@ - New Contract + New Contract diff --git a/addons/hr/tests/test_hr_version.py b/addons/hr/tests/test_hr_version.py index 239ce9c4c22fc5..21db61e7e216df 100644 --- a/addons/hr/tests/test_hr_version.py +++ b/addons/hr/tests/test_hr_version.py @@ -523,27 +523,6 @@ def test_multi_edit_other_and_contract_date_sync(self): self.assertEqual(version.job_id.id, jobB.id) self.assertEqual(version.contract_date_end, date(2020, 9, 30)) - def test_delete_version(self): - employee = self.env['hr.employee'].create({ - 'name': 'John Doe', - 'date_version': '2020-01-01', - }) - v1 = employee.version_id - v2 = employee.create_version({ - 'date_version': '2021-01-01', - }) - v3 = employee.create_version({ - 'date_version': '2022-01-01', - }) - self.assertEqual(employee.current_version_id, v3) - - v3.unlink() - self.assertEqual(employee.current_version_id, v2) - v1.unlink() - self.assertEqual(employee.current_version_id, v2) - with self.assertRaises(ValidationError): - v2.unlink() - def test_multi_edit_multi_employees_no_contract(self): """ Test the multi-edit when there is one version per employee, without contract diff --git a/addons/hr/views/hr_employee_views.xml b/addons/hr/views/hr_employee_views.xml index aeda9df6da40d0..2215f75de30389 100644 --- a/addons/hr/views/hr_employee_views.xml +++ b/addons/hr/views/hr_employee_views.xml @@ -375,7 +375,7 @@ to - + diff --git a/addons/hr_holidays/static/src/components/accrual_level/accrual_levels.scss b/addons/hr_holidays/static/src/components/accrual_level/accrual_levels.scss index 9cec634e1b2dd5..5ea81942c9be6c 100644 --- a/addons/hr_holidays/static/src/components/accrual_level/accrual_levels.scss +++ b/addons/hr_holidays/static/src/components/accrual_level/accrual_levels.scss @@ -10,7 +10,7 @@ } .o_accrual { - .o_field_accrual, .o_field_selection, .o_field_day_selection, .o_field_filterable_selection { + .o_field_accrual, .o_field_selection, .o_field_filterable_selection { width: fit-content !important; &:not(.o_readonly_modifier) > *:first-child { @@ -20,7 +20,7 @@ field-sizing: content; } - &:not(.o_field_selection, .o_field_day_selection, .o_field_filterable_selection) > *:first-child { + &:not(.o_field_selection, .o_field_filterable_selection) > *:first-child { max-width: 8ch; } } diff --git a/addons/hr_holidays/static/src/components/day_selection/day_selection.js b/addons/hr_holidays/static/src/components/day_selection/day_selection.js deleted file mode 100644 index 05288069a543bc..00000000000000 --- a/addons/hr_holidays/static/src/components/day_selection/day_selection.js +++ /dev/null @@ -1,41 +0,0 @@ -import { registry } from "@web/core/registry"; -import { SelectionField, selectionField } from "@web/views/fields/selection/selection_field"; - -export class DaySelectionField extends SelectionField { - static props = { - ...SelectionField.props, - monthField: String, - }; - /** - * @override - * return the available days in the carryover_month - * e.g. February -> [1, 29], april -> [1, 30] - */ - get options() { - let options = super.options; - const carryover_month = this.props.record.data[this.props.monthField]; - // lastDay is the last day of the current_month for the leap year 2020 - const lastDay = new Date(2020, carryover_month, 0).getDate(); - options = options.filter((option) => option[0] <= lastDay); - return options; - } -} - -export const daySelectionField = { - ...selectionField, - component: DaySelectionField, - extractProps({ attrs }) { - return { - ...selectionField.extractProps(...arguments), - monthField: attrs.month_field, - }; - }, - fieldDependencies: ({ attrs }) => [ - { - name: attrs.month_field, - type: "selection", - }, - ], -}; - -registry.category("fields").add("day_selection", daySelectionField); diff --git a/addons/hr_holidays/tests/test_hr_work_entry_type.py b/addons/hr_holidays/tests/test_hr_work_entry_type.py index aca98678c86190..b7289ae374d014 100644 --- a/addons/hr_holidays/tests/test_hr_work_entry_type.py +++ b/addons/hr_holidays/tests/test_hr_work_entry_type.py @@ -232,3 +232,55 @@ def test_change_count_days_as(self): with self.assertRaises(ValidationError): work_entry_type.count_days_as = 'working' + + def test_compute_virtual_remaining_leaves(self): + """Compute virtual remaining leaves during selection in time off creation""" + country_id = self.env.ref('base.id') + + work_entry_type = self.env['hr.work.entry.type'].create({ + 'name': 'Cuti Melahirkan', + 'code': 'leave8080', + 'requires_allocation': 'yes', + 'count_days_as': 'working', + 'country_id': country_id.id, + 'active': True, + 'request_unit': 'day', + 'unit_of_measure': 'day', + }) + + employee = self.env['hr.employee'].create({ + 'name': 'Pria Solo', + 'work_email': 'solo@example.com', + 'country_id': country_id.id, + }) + + employee_allocation = self.env['hr.leave.allocation'].create({ + 'name': 'Annual Allocation for Pria Solo', + 'employee_id': employee.id, + 'work_entry_type_id': work_entry_type.id, + 'number_of_days': 10.0, # 10 days = 80 hours + 'date_from': date(2026, 5, 1), + 'date_to': date(2026, 5, 31), + }) + + employee_allocation._action_validate() + work_entry_ctx = work_entry_type.with_context(employee_id=employee.id) + + leave_request = self.env['hr.leave'].create({ + 'name': 'Budi Taking 3 Days Off', + 'employee_id': employee.id, + 'work_entry_type_id': work_entry_type.id, + 'request_date_from': date(2026, 5, 10), + 'request_date_to': date(2026, 5, 12), # 2 days + }) + leave_request.action_approve() + + work_entry_type.invalidate_recordset(['virtual_remaining_leaves']) + + current_virtual = work_entry_ctx.virtual_remaining_leaves + + res_ids = work_entry_ctx._search_virtual_remaining_leaves(">", 5)[0][2] + + # 7. Final Assertions + self.assertEqual(current_virtual, 8, "The remaining virtual leaves should be after deducted by 2 days") + self.assertIn(work_entry_type.id, res_ids, "The work entry type should be found in the search results") diff --git a/addons/hr_holidays/views/hr_leave_accrual_views.xml b/addons/hr_holidays/views/hr_leave_accrual_views.xml index fedc5058fa94d4..a097fdbec8f74b 100644 --- a/addons/hr_holidays/views/hr_leave_accrual_views.xml +++ b/addons/hr_holidays/views/hr_leave_accrual_views.xml @@ -36,17 +36,17 @@ on the - + of and the - + of on the - + of @@ -195,7 +195,7 @@ options="{'links': {'other': 'carryover_custom_date'}, 'observe': 'carryover'}"/> : the - of = '%(date)s') AND s.valid_from <= '%(date)s' AS active + FROM hr_employee e + LEFT JOIN hr_version v ON e.current_version_id = v.id + LEFT OUTER JOIN hr_employee_skill s ON e.id = s.employee_id + LEFT OUTER JOIN hr_skill_level sl ON sl.id = s.skill_level_id + LEFT OUTER JOIN hr_skill_type st ON st.id = sl.skill_type_id + WHERE e.active AND st.active IS True AND st.is_certification IS TRUE + ) + """ % { + 'table': self._table, + 'date': fields.Date.context_today(self) + }) diff --git a/addons/hr_skills/report/hr_employee_certification_report_views.xml b/addons/hr_skills/report/hr_employee_certification_report_views.xml new file mode 100644 index 00000000000000..079ef1f790fd91 --- /dev/null +++ b/addons/hr_skills/report/hr_employee_certification_report_views.xml @@ -0,0 +1,71 @@ + + + + hr.employee.certification.report + + + + + + + + + + + + hr.employee.certification.report + + + + + + + + + + + + + hr.employee.certification.report + + + + + + + + + + + + + + + + + + + + Certification + hr.employee.certification.report + + list,pivot + { + 'search_default_employee': 1, + } + + + + This report will give you an overview of the certification per Employee. + Create them in configuration and add them on the Employee. + + + + + + diff --git a/addons/hr_skills/report/hr_employee_skill_report_views.xml b/addons/hr_skills/report/hr_employee_skill_report_views.xml index 86b997da5ffbbe..bddca497eb6efa 100644 --- a/addons/hr_skills/report/hr_employee_skill_report_views.xml +++ b/addons/hr_skills/report/hr_employee_skill_report_views.xml @@ -89,6 +89,6 @@ id="hr_employee_skill_inventory_report_menu" name="Skills Inventory" action="hr_employee_skill_report_action" - parent="hr.hr_menu_hr_reports" + parent="hr_skills.hr_employee_skill_report_menu" sequence="15"/> diff --git a/addons/hr_skills/views/hr_views.xml b/addons/hr_skills/views/hr_views.xml index 582a73545e85cb..30c25016ea019d 100644 --- a/addons/hr_skills/views/hr_views.xml +++ b/addons/hr_skills/views/hr_views.xml @@ -589,7 +589,7 @@ hr.employee.skill certifications [('is_certification', '=', True), ('company_id', 'in', allowed_company_ids)] - {'show_employee': True} + {'show_employee': True, 'search_default_group_by_type': 1} list,form + +
+
+ This report will give you an overview of the certification per Employee. + Create them in configuration and add them on the Employee. +