Merge pull request #40203 from barredterra/filter-project-department

diff --git a/erpnext/projects/doctype/project/project.js b/erpnext/projects/doctype/project/project.js
index 2dac399..e0dd198 100644
--- a/erpnext/projects/doctype/project/project.js
+++ b/erpnext/projects/doctype/project/project.js
@@ -35,6 +35,14 @@
 			};
 		});
 
+		frm.set_query("department", function (doc) {
+			return {
+				filters: {
+					"company": doc.company,
+				}
+			};
+		});
+
 		// sales order
 		frm.set_query('sales_order', function () {
 			var filters = {