This commit is contained in:
gitea 2025-01-21 13:11:12 +00:00
parent 43e1c7640f
commit 042d1ac34b
2 changed files with 5 additions and 7 deletions

View File

@ -3106,8 +3106,8 @@ def bill_create(request):
terms = data.get("terms") terms = data.get("terms")
vendor = entity.get_vendors().filter(pk=vendor_id).first() vendor = entity.get_vendors().filter(pk=vendor_id).first()
items = data.get("item", []) items = data.get("item[]", [])
quantities = data.get("quantity", []) quantities = data.get("quantity[]", [])
if not all([items, quantities]): if not all([items, quantities]):
return JsonResponse( return JsonResponse(
@ -3183,7 +3183,7 @@ def bill_create(request):
return JsonResponse( return JsonResponse(
{ {
"status": "success", "status": "success",
"message": "Estimate created successfully!", "message": "Bill created successfully!",
"url": f"{url}", "url": f"{url}",
} }
) )

View File

@ -115,7 +115,6 @@
quantity: [] quantity: []
}; };
// Collect multi-value fields (e.g., item[], quantity[]) // Collect multi-value fields (e.g., item[], quantity[])
document.querySelectorAll('[name="item[]"]').forEach(input => { document.querySelectorAll('[name="item[]"]').forEach(input => {
formData.item.push(input.value); formData.item.push(input.value);
@ -123,8 +122,7 @@
document.querySelectorAll('[name="quantity[]"]').forEach(input => { document.querySelectorAll('[name="quantity[]"]').forEach(input => {
formData.quantity.push(input.value); formData.quantity.push(input.value);
}); });
console.log(formData); console.log(formData)
try { try {
// Send data to the server using fetch // Send data to the server using fetch
const response = await fetch("{% url 'bill_create' %}", { const response = await fetch("{% url 'bill_create' %}", {