Initial commit: fixtures, hooks, doctype events, API, and JS
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import frappe
|
||||
|
||||
def calculate_totals(doc, method):
|
||||
"""Auto-calculate Load totals from child tables."""
|
||||
total_devices = 0
|
||||
total_weight = 0.0
|
||||
|
||||
for item in doc.get("material_items", []):
|
||||
total_devices += item.total_count or 0
|
||||
total_weight += item.weight or 0.0
|
||||
|
||||
doc.total_devices = total_devices
|
||||
doc.total_weight = total_weight
|
||||
|
||||
total_hdd_wiped = 0
|
||||
total_hdd_degaussed = 0
|
||||
|
||||
for hdd in doc.get("hdd_serials", []):
|
||||
if hdd.wiped:
|
||||
total_hdd_wiped += 1
|
||||
if hdd.degaussed or hdd.shredded:
|
||||
total_hdd_degaussed += 1
|
||||
|
||||
doc.total_hdd_wiped = total_hdd_wiped
|
||||
doc.total_hdd_degaussed = total_hdd_degaussed
|
||||
@@ -0,0 +1,7 @@
|
||||
import frappe
|
||||
|
||||
def update_serial_nos(doc, method):
|
||||
"""Update serial nos linked to this pallet."""
|
||||
if doc.pallet_number:
|
||||
serials = frappe.get_all("Serial No", filters={"pallet": doc.pallet_number}, fields=["name"])
|
||||
doc.db_set("serial_count", len(serials))
|
||||
@@ -0,0 +1,8 @@
|
||||
import frappe
|
||||
|
||||
def set_title(doc, method):
|
||||
"""Set title from company name and pickup date."""
|
||||
if doc.company_name and doc.pickup_date:
|
||||
doc.title = f"{doc.company_name} - {doc.pickup_date}"
|
||||
elif doc.company_name:
|
||||
doc.title = doc.company_name
|
||||
Reference in New Issue
Block a user