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:
@@ -5,10 +5,23 @@ router = APIRouter(prefix="/api/tasks", tags=["tasks"])
|
||||
|
||||
@router.get("/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()
|
||||
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 = []
|
||||
for project in projects:
|
||||
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", []),
|
||||
"priority": task.get("priority", "0"),
|
||||
"deadline": task.get("date_deadline"),
|
||||
"kanban_state": task.get("kanban_state", "normal"),
|
||||
})
|
||||
result.append({
|
||||
"id": project["id"],
|
||||
|
||||
Reference in New Issue
Block a user