feat: batch material override — apply to all lines in an order at once

- POST /orders/{id}/batch-material-override endpoint
- Dropdown above the lines table: "Apply to all lines…"
- Options: clear all overrides, or select a library material
- Updates all order lines in one request

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-14 14:36:18 +01:00
parent 9d6def84c1
commit d84ce8252e
3 changed files with 71 additions and 1 deletions
+26
View File
@@ -1097,6 +1097,32 @@ async def dispatch_single_line_render(
return {"dispatched": True, "line_id": str(line.id)}
class BatchMaterialOverrideBody(BaseModel):
material_override: str | None = None
@router.post("/{order_id}/batch-material-override")
async def batch_material_override(
order_id: uuid.UUID,
body: BatchMaterialOverrideBody,
user: User = Depends(require_admin_or_pm),
db: AsyncSession = Depends(get_db),
):
"""Set material_override on ALL lines of an order at once."""
result = await db.execute(select(Order).where(Order.id == order_id))
if not result.scalar_one_or_none():
raise HTTPException(404, detail="Order not found")
from sqlalchemy import update as sql_update
res = await db.execute(
sql_update(OrderLine)
.where(OrderLine.order_id == order_id)
.values(material_override=body.material_override)
)
await db.commit()
return {"updated": res.rowcount, "material_override": body.material_override}
class PatchLineBody(BaseModel):
material_override: str | None = None