diff --git a/addons/hr/static/src/components/hr_presence_status_private/hr_presence_status_private.js b/addons/hr/static/src/components/hr_presence_status_private/hr_presence_status_private.js
new file mode 100644
index 00000000000..9ad4f7b1cd5
--- /dev/null
+++ b/addons/hr/static/src/components/hr_presence_status_private/hr_presence_status_private.js
@@ -0,0 +1,13 @@
+/** @odoo-module */
+
+import { registry } from "@web/core/registry";
+import { HrPresenceStatus, hrPresenceStatus } from "../hr_presence_status/hr_presence_status";
+
+export class HrPresenceStatusPrivate extends HrPresenceStatus { }
+
+export const hrPresenceStatusPrivate = {
+ ...hrPresenceStatus,
+ component: HrPresenceStatusPrivate,
+};
+
+registry.category("fields").add("hr_presence_status_private", hrPresenceStatusPrivate);
diff --git a/addons/hr/views/hr_employee_public_views.xml b/addons/hr/views/hr_employee_public_views.xml
index 42d140c4874..51c23f75cb6 100644
--- a/addons/hr/views/hr_employee_public_views.xml
+++ b/addons/hr/views/hr_employee_public_views.xml
@@ -158,9 +158,6 @@
- -
-
-
-
diff --git a/addons/hr_holidays/static/src/components/hr_presence_status/hr_presence_status.js b/addons/hr_holidays/static/src/components/hr_presence_status/hr_presence_status.js
index ba21d43b54f..7f66753e383 100644
--- a/addons/hr_holidays/static/src/components/hr_presence_status/hr_presence_status.js
+++ b/addons/hr_holidays/static/src/components/hr_presence_status/hr_presence_status.js
@@ -3,8 +3,9 @@
import { patch } from "@web/core/utils/patch";
import { HrPresenceStatus } from "@hr/components/hr_presence_status/hr_presence_status";
+import { HrPresenceStatusPrivate, hrPresenceStatusPrivate } from "@hr/components/hr_presence_status_private/hr_presence_status_private";
-patch(HrPresenceStatus.prototype, {
+const patchHrPresenceStatus = () => ({
get icon() {
if (this.value.startsWith("presence_holiday")) {
return "fa-plane";
@@ -19,3 +20,23 @@ patch(HrPresenceStatus.prototype, {
return super.color;
},
});
+
+// Applies common patch on both components
+patch(HrPresenceStatus.prototype, patchHrPresenceStatus());
+patch(HrPresenceStatusPrivate.prototype, patchHrPresenceStatus());
+
+// Applies patch to hr_presence_status_private to display the time off type instead of default label
+patch(HrPresenceStatusPrivate.prototype, {
+ get label() {
+ return this.props.record.data.current_leave_id
+ ? this.props.record.data.current_leave_id[1]
+ : super.label;
+ }
+});
+
+Object.assign(hrPresenceStatusPrivate, {
+ fieldDependencies: [
+ ...(hrPresenceStatusPrivate.fieldDependencies || []),
+ { name: "current_leave_id", type:"many2one"}
+ ],
+});
diff --git a/addons/hr_holidays/views/hr_views.xml b/addons/hr_holidays/views/hr_views.xml
index 6e8dbcea437..a9b369eb5a1 100644
--- a/addons/hr_holidays/views/hr_views.xml
+++ b/addons/hr_holidays/views/hr_views.xml
@@ -109,6 +109,9 @@
+
+ hr_presence_status_private
+
diff --git a/addons/hr_homeworking/static/src/components/hr_presence_status/hr_presence_status.js b/addons/hr_homeworking/static/src/components/hr_presence_status/hr_presence_status.js
index ced6c43b08f..3bbb437738f 100644
--- a/addons/hr_homeworking/static/src/components/hr_presence_status/hr_presence_status.js
+++ b/addons/hr_homeworking/static/src/components/hr_presence_status/hr_presence_status.js
@@ -1,11 +1,11 @@
/** @odoo-module **/
-import { _t } from "@web/core/l10n/translation";
import { patch } from "@web/core/utils/patch";
import { HrPresenceStatus, hrPresenceStatus } from "@hr/components/hr_presence_status/hr_presence_status";
+import { HrPresenceStatusPrivate, hrPresenceStatusPrivate } from "@hr/components/hr_presence_status_private/hr_presence_status_private";
-patch(HrPresenceStatus.prototype, {
+const patchHrPresenceStatus = () => ({
get color() {
if (this.location) {
let color = "text-muted";
@@ -31,13 +31,6 @@ patch(HrPresenceStatus.prototype, {
return super.icon;
},
- get label() {
- if (this.location) {
- return _t("Working from %s", this.location);
- }
- return super.label;
- },
-
get location() {
let location = this.value?.split("_")[1] || "";
if (location && !['home', 'office', 'other'].includes(location)) {
@@ -45,10 +38,22 @@ patch(HrPresenceStatus.prototype, {
}
return location;
},
+
+ get label() {
+ if (this.location) {
+ return this.props.record.data.name_work_location_display;
+ }
+ return super.label;
+ },
});
+// for the both components: first applies the common patch and then applies patch for label
+patch(HrPresenceStatus.prototype, patchHrPresenceStatus());
+patch(HrPresenceStatusPrivate.prototype, patchHrPresenceStatus());
+
const additionalFieldDependencies = [
{ name: "hr_presence_state", type: "selection" },
+ { name: "name_work_location_display", type: "char" }
];
if (typeof hrPresenceStatus.fieldDependencies === "function") {
const oldFieldDependencies = hrPresenceStatus.fieldDependencies;
@@ -63,3 +68,7 @@ if (typeof hrPresenceStatus.fieldDependencies === "function") {
...additionalFieldDependencies,
];
}
+hrPresenceStatusPrivate.fieldDependencies = [
+ ...(hrPresenceStatusPrivate.fieldDependencies || []),
+ ...additionalFieldDependencies,
+];