Limit InvenTree part descriptions

This commit is contained in:
2026-04-15 14:07:43 +03:00
parent 81bd32c4b1
commit 1834c7c369
2 changed files with 3 additions and 6 deletions

View File

@@ -46,7 +46,7 @@ class InvenTreeClient:
async def create_part(self, *, name: str, description: str, ipn: str) -> dict[str, Any]: async def create_part(self, *, name: str, description: str, ipn: str) -> dict[str, Any]:
payload = { payload = {
"name": name[:100], "name": name[:100],
"description": description, "description": description[:250],
"category": self.settings.inventree_part_category_id, "category": self.settings.inventree_part_category_id,
"IPN": ipn[:100], "IPN": ipn[:100],
"active": True, "active": True,

View File

@@ -235,20 +235,17 @@ class ArchiveSyncService:
return f"Bambuddy archive {archive.id}" return f"Bambuddy archive {archive.id}"
def description_for_archive(self, archive: Archive) -> str: def description_for_archive(self, archive: Archive) -> str:
return "\n".join( description = "\n".join(
line line
for line in [ for line in [
"Auto-created from Bambuddy archive.", "Auto-created from Bambuddy archive.",
f"Archive ID: {archive.id}", f"Archive ID: {archive.id}",
f"Print name: {archive.print_name}" if archive.print_name else "", f"Print name: {archive.print_name}" if archive.print_name else "",
f"Filename: {archive.filename}" if archive.filename else "", f"Filename: {archive.filename}" if archive.filename else "",
f"Content hash: {archive.content_hash}" if archive.content_hash else "",
f"Printer: {archive.printer_name}" if archive.printer_name else "",
f"Created at: {archive.created_at}" if archive.created_at else "",
f"Completed at: {archive.completed_at}" if archive.completed_at else "",
] ]
if line if line
) )
return description[:250]
def stock_notes_for_archive(self, archive: Archive) -> str: def stock_notes_for_archive(self, archive: Archive) -> str:
duration = archive.actual_time_seconds or archive.print_time_seconds or archive.duration duration = archive.actual_time_seconds or archive.print_time_seconds or archive.duration