diff --git a/addons/hr_timesheet/static/src/components/progress_bar/project_task_progress_bar_field.js b/addons/hr_timesheet/static/src/components/progress_bar/project_task_progress_bar_field.js
new file mode 100644
index 00000000000..c4159637ed9
--- /dev/null
+++ b/addons/hr_timesheet/static/src/components/progress_bar/project_task_progress_bar_field.js
@@ -0,0 +1,21 @@
+/** @odoo-module **/
+
+import { registry } from "@web/core/registry";
+import { progressBarField, ProgressBarField } from "@web/views/fields/progress_bar/progress_bar_field";
+
+export class ProjectTaskProgressBarField extends ProgressBarField {
+ get progressBarColorClass() {
+ if (this.currentValue > this.maxValue) {
+ return super.progressBarColorClass;
+ }
+
+ return this.currentValue < 80 ? "bg-success" : "bg-warning";
+ }
+}
+
+export const projectTaskProgressBarField = {
+ ...progressBarField,
+ component: ProjectTaskProgressBarField,
+};
+
+registry.category("fields").add("project_task_progressbar", projectTaskProgressBarField);
diff --git a/addons/hr_timesheet/static/tests/hr_timesheet_common_tests.js b/addons/hr_timesheet/static/tests/hr_timesheet_common_tests.js
index e04f1dc8c88..a3c72c26bf3 100644
--- a/addons/hr_timesheet/static/tests/hr_timesheet_common_tests.js
+++ b/addons/hr_timesheet/static/tests/hr_timesheet_common_tests.js
@@ -35,11 +35,12 @@ export const getServerData = () => JSON.parse(JSON.stringify({
fields: {
name: { string: "Name", type: "string" },
project_id: { string: "Project", type: "many2one", relation: "project.project" },
+ progress: { string: "progress", type: "float" },
},
records: [
- { id: 1, name: "Task 1\u00A0AdditionalInfo", project_id: 1 },
- { id: 2, name: "Task 2\u00A0AdditionalInfo", project_id: 1 },
- { id: 3, name: "Task 3\u00A0AdditionalInfo", project_id: 1 },
+ { id: 1, name: "Task 1\u00A0AdditionalInfo", project_id: 1, progress: 50 },
+ { id: 2, name: "Task 2\u00A0AdditionalInfo", project_id: 1, progress: 80 },
+ { id: 3, name: "Task 3\u00A0AdditionalInfo", project_id: 1, progress: 104 },
],
},
},
diff --git a/addons/hr_timesheet/static/tests/task_with_hours_tests.js b/addons/hr_timesheet/static/tests/task_with_hours_tests.js
index 2767d143681..0f283cc3db4 100644
--- a/addons/hr_timesheet/static/tests/task_with_hours_tests.js
+++ b/addons/hr_timesheet/static/tests/task_with_hours_tests.js
@@ -64,4 +64,22 @@ QUnit.module("hr_timesheet", (hooks) => {
assert.containsN(firstRow, '.o_list_many2one[name=task_id] .dropdown ul li:contains("AdditionalInfo")', 3);
});
+ QUnit.test("project task progress bar color", async function (assert) {
+ await makeView({
+ serverData,
+ type: "list",
+ resModel: "project.task",
+ arch: `
+
You can discard these changes from here or manually save your task.
Let's save it manually.")),
- position: "bottom",
}, {
trigger: ".breadcrumb-item:not(.active):last",
extra_trigger: '.o_form_project_tasks',
diff --git a/addons/web/static/src/views/fields/progress_bar/progress_bar_field.js b/addons/web/static/src/views/fields/progress_bar/progress_bar_field.js
index 65cfe2e0378..36dfb1102e6 100644
--- a/addons/web/static/src/views/fields/progress_bar/progress_bar_field.js
+++ b/addons/web/static/src/views/fields/progress_bar/progress_bar_field.js
@@ -54,6 +54,10 @@ export class ProgressBarField extends Component {
return this.props.record.data[this.maxValueField] || 100;
}
+ get progressBarColorClass() {
+ return this.currentValue > this.maxValue ? this.props.overflowClass : "bg-primary";
+ }
+
formatCurrentValue(humanReadable = !this.state.isEditing) {
const formatter = formatters.get(Number.isInteger(this.currentValue) ? "integer" : "float");
return formatter(this.currentValue, { humanReadable });
diff --git a/addons/web/static/src/views/fields/progress_bar/progress_bar_field.xml b/addons/web/static/src/views/fields/progress_bar/progress_bar_field.xml
index 89ea503af32..835289a980a 100644
--- a/addons/web/static/src/views/fields/progress_bar/progress_bar_field.xml
+++ b/addons/web/static/src/views/fields/progress_bar/progress_bar_field.xml
@@ -5,7 +5,7 @@