filter: exclude CAS 3D projects from dashboard
Add exclude_company_ids config in settings.yaml to filter out projects by Odoo company_id. Currently excludes company_id=2 (CAS 3D), keeping only Consultoria AS and unassigned projects. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,7 @@ odoo:
|
|||||||
database: "cas"
|
database: "cas"
|
||||||
username: "ialcarazsalazar@consultoria-as.com"
|
username: "ialcarazsalazar@consultoria-as.com"
|
||||||
password: "Aasi940812"
|
password: "Aasi940812"
|
||||||
|
exclude_company_ids: [2] # Excluir CAS 3D
|
||||||
|
|
||||||
refresh:
|
refresh:
|
||||||
odoo_minutes: 5
|
odoo_minutes: 5
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ class OdooClient:
|
|||||||
return await self.search_read(
|
return await self.search_read(
|
||||||
model="project.project",
|
model="project.project",
|
||||||
domain=[("active", "=", True)],
|
domain=[("active", "=", True)],
|
||||||
fields=["name", "task_count", "color"],
|
fields=["name", "task_count", "color", "company_id"],
|
||||||
)
|
)
|
||||||
|
|
||||||
async def get_tasks(self, project_id: int | None = None) -> list[dict[str, Any]]:
|
async def get_tasks(self, project_id: int | None = None) -> list[dict[str, Any]]:
|
||||||
|
|||||||
@@ -5,10 +5,23 @@ router = APIRouter(prefix="/api/tasks", tags=["tasks"])
|
|||||||
|
|
||||||
@router.get("/by-project")
|
@router.get("/by-project")
|
||||||
async def get_tasks_by_project():
|
async def get_tasks_by_project():
|
||||||
from main import odoo_client
|
from main import odoo_client, app_config
|
||||||
|
|
||||||
|
settings = app_config.get_settings()
|
||||||
|
exclude_ids = settings.get("odoo", {}).get("exclude_company_ids", [])
|
||||||
|
|
||||||
projects = await odoo_client.get_projects()
|
projects = await odoo_client.get_projects()
|
||||||
tasks = await odoo_client.get_tasks()
|
tasks = await odoo_client.get_tasks()
|
||||||
|
|
||||||
|
# Filter out excluded companies
|
||||||
|
if exclude_ids:
|
||||||
|
projects = [
|
||||||
|
p for p in projects
|
||||||
|
if not (isinstance(p.get("company_id"), list) and p["company_id"][0] in exclude_ids)
|
||||||
|
]
|
||||||
|
project_ids = {p["id"] for p in projects}
|
||||||
|
tasks = [t for t in tasks if t.get("project_id") and t["project_id"][0] in project_ids]
|
||||||
|
|
||||||
result = []
|
result = []
|
||||||
for project in projects:
|
for project in projects:
|
||||||
project_tasks = [t for t in tasks if t.get("project_id") and t["project_id"][0] == project["id"]]
|
project_tasks = [t for t in tasks if t.get("project_id") and t["project_id"][0] == project["id"]]
|
||||||
@@ -21,7 +34,6 @@ async def get_tasks_by_project():
|
|||||||
"assigned": task.get("user_ids", []),
|
"assigned": task.get("user_ids", []),
|
||||||
"priority": task.get("priority", "0"),
|
"priority": task.get("priority", "0"),
|
||||||
"deadline": task.get("date_deadline"),
|
"deadline": task.get("date_deadline"),
|
||||||
"kanban_state": task.get("kanban_state", "normal"),
|
|
||||||
})
|
})
|
||||||
result.append({
|
result.append({
|
||||||
"id": project["id"],
|
"id": project["id"],
|
||||||
|
|||||||
Reference in New Issue
Block a user